* @param [options] - see Light3dOptions
(options: Light3dOptions = {})
| 70 | * @param [options] - see {@link Light3dOptions} |
| 71 | */ |
| 72 | constructor(options: Light3dOptions = {}) { |
| 73 | // a light has no visual footprint — a sizeless renderable at the origin |
| 74 | super(0, 0, 0, 0); |
| 75 | |
| 76 | this.type = options.type ?? "directional"; |
| 77 | |
| 78 | this.direction = new Vector3d(0, 1, 0); |
| 79 | if (options.direction) { |
| 80 | this.direction.set( |
| 81 | options.direction[0], |
| 82 | options.direction[1], |
| 83 | options.direction[2], |
| 84 | ); |
| 85 | } |
| 86 | this.direction.normalize(); |
| 87 | |
| 88 | this.position = new Vector3d(0, 0, 0); |
| 89 | if (options.position) { |
| 90 | this.position.set( |
| 91 | options.position[0], |
| 92 | options.position[1], |
| 93 | options.position[2], |
| 94 | ); |
| 95 | } |
| 96 | |
| 97 | if (options.color instanceof Color) { |
| 98 | this.color = options.color; |
| 99 | } else if (Array.isArray(options.color)) { |
| 100 | // glTF convention: [r, g, b] in 0..1 |
| 101 | this.color = new Color( |
| 102 | options.color[0] * 255, |
| 103 | options.color[1] * 255, |
| 104 | options.color[2] * 255, |
| 105 | 1, |
| 106 | ); |
| 107 | } else if (typeof options.color === "string") { |
| 108 | this.color = new Color().parseCSS(options.color); |
| 109 | } else { |
| 110 | this.color = new Color(255, 255, 255, 1); |
| 111 | } |
| 112 | |
| 113 | this.intensity = options.intensity ?? 1; |
| 114 | |
| 115 | // nothing to draw, and no transform to apply — keep it off the |
| 116 | // renderer-state path entirely |
| 117 | this.autoTransform = false; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Register with the active stage's 3D-light set on activation (when added to |