|
41 | 41 | "}", |
42 | 42 | "", |
43 | 43 | "/**", |
44 | | - " * @typedef {gdjs.RuntimeObject & {__cameraDistance: number, __spotLight: THREE.SpotLight, _getIsCastingShadow: () => boolean}} SpotLightRuntimeObject", |
| 44 | + " * @typedef {gdjs.CustomRuntimeObject3D & {__cameraDistance: number, __spotLight: THREE.SpotLight, _getIsCastingShadow: () => boolean, _getConeAngle: () => number, _getColor: () => string}} SpotLightRuntimeObject", |
45 | 45 | " */", |
46 | 46 | "", |
47 | 47 | "const game = runtimeScene.getGame();", |
|
59 | 59 | " }", |
60 | 60 | "", |
61 | 61 | " _updateThreeGroup() {", |
62 | | - " const object = this._object;", |
63 | | - " /** @type {THREE.SpotLight} */", |
| 62 | + " /** @type {SpotLightRuntimeObject} */", |
64 | 63 | " //@ts-ignore", |
| 64 | + " const object = this._object;", |
65 | 65 | " const threeObject3D = this.get3DRendererObject();", |
66 | 66 | "", |
67 | 67 | " threeObject3D.rotation.set(", |
|
85 | 85 | "", |
86 | 86 | " threeObject3D.visible = !this._object.hidden;", |
87 | 87 | "", |
88 | | - " /** @type {THREE.SpotLight} */", |
89 | | - " //@ts-ignore", |
90 | 88 | " const spotLight = object.__spotLight;", |
91 | 89 | "", |
92 | 90 | " const editor = game.getInGameEditor ? game.getInGameEditor() : null;", |
|
129 | 127 | " const deltaZ = rootObject.getZ() - cameraZ;", |
130 | 128 | " distanceSq = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;", |
131 | 129 | " }", |
132 | | - " //@ts-ignore", |
133 | | - " const distanceMax = object._getVisibilityDistanceMax();", |
134 | | - " const isWithInRange = distanceSq <= distanceMax * distanceMax;", |
135 | | - " if (isWithInRange) {", |
136 | | - " getSpotLightManager(", |
137 | | - " //@ts-ignore", |
138 | | - " runtimeScene", |
139 | | - " ).applyVisibilityAndShadow(object, distanceSq);", |
140 | | - " }", |
141 | | - "", |
| 130 | + " getSpotLightManager(", |
| 131 | + " //@ts-ignore", |
| 132 | + " runtimeScene", |
| 133 | + " ).applyVisibilityAndShadow(object, distanceSq);", |
142 | 134 | " }", |
143 | 135 | "", |
144 | 136 | " // Force the visibility to be checked every frame", |
|
263 | 255 | "const coneLength = 64;", |
264 | 256 | "", |
265 | 257 | "class SpotLightHelper extends THREE.Object3D {", |
266 | | - " /** @type {gdjs.CustomRuntimeObject3D} */", |
| 258 | + " /** @type {SpotLightRuntimeObject} */", |
267 | 259 | " object;", |
268 | | - " /** @type {THREE.LineSegments} */", |
| 260 | + " /** @type {THREE.LineSegments<THREE.BufferGeometry, THREE.LineBasicMaterial>} */", |
269 | 261 | " cone;", |
270 | | - " /** @type {THREE.LineSegments} */", |
| 262 | + " /** @type {THREE.LineSegments<THREE.BufferGeometry, THREE.LineBasicMaterial>} */", |
271 | 263 | " centerLine;", |
272 | | - " /** @type {THREE.Mesh} */", |
| 264 | + " /** @type {THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>} */", |
273 | 265 | " originBox;", |
274 | 266 | "", |
275 | 267 | "\t/**", |
276 | | - " * @param {gdjs.CustomRuntimeObject3D} object", |
| 268 | + " * @param {SpotLightRuntimeObject} object", |
277 | 269 | "\t */", |
278 | 270 | " constructor(object) {", |
279 | 271 | " super();", |
|
325 | 317 | "", |
326 | 318 | " dispose() {", |
327 | 319 | " this.cone.geometry.dispose();", |
328 | | - " //@ts-ignore", |
329 | 320 | " this.cone.material.dispose();", |
330 | 321 | " this.centerLine.geometry.dispose();", |
331 | | - " //@ts-ignore", |
332 | 322 | " this.centerLine.material.dispose();", |
333 | 323 | " this.originBox.geometry.dispose();", |
334 | | - " //@ts-ignore", |
335 | 324 | " this.originBox.material.dispose();", |
336 | 325 | " }", |
337 | 326 | "", |
338 | 327 | " update() {", |
339 | 328 | " /** @type {number} */", |
340 | | - " //@ts-ignore", |
341 | 329 | " const coneAngle = gdjs.toRad(this.object._getConeAngle());", |
342 | 330 | " const coneWidth = coneLength * Math.sin(coneAngle);", |
343 | 331 | " const coneHeight = coneLength * Math.cos(coneAngle);", |
344 | 332 | " this.cone.scale.set(coneHeight, coneWidth, coneWidth);", |
345 | | - " /** @type {number} */", |
346 | | - " //@ts-ignore", |
347 | | - " const color = gdjs.rgbOrHexStringToNumber(this.object._getColor())", |
348 | | - " /** @type {THREE.LineBasicMaterial} */", |
349 | | - " //@ts-ignore", |
350 | | - " const coneMaterial = this.cone.material;", |
351 | | - " coneMaterial.color.set(color);", |
352 | | - " /** @type {THREE.LineBasicMaterial} */", |
353 | | - " //@ts-ignore", |
354 | | - " const centerLineMaterial = this.centerLine.material;", |
355 | | - " centerLineMaterial.color.set(color);", |
356 | | - " /** @type {THREE.MeshBasicMaterial} */", |
357 | | - " //@ts-ignore", |
358 | | - " const originBoxMaterial = this.originBox.material;", |
359 | | - " originBoxMaterial.color.set(color);", |
| 333 | + " const color = gdjs.rgbOrHexStringToNumber(this.object._getColor());", |
| 334 | + " this.cone.material.color.set(color);", |
| 335 | + " this.centerLine.material.color.set(color);", |
| 336 | + " this.originBox.material.color.set(color);", |
360 | 337 | " }", |
361 | 338 | "}", |
362 | 339 | "", |
|
2119 | 2096 | "group": "Shadow", |
2120 | 2097 | "name": "IsCastingShadow" |
2121 | 2098 | }, |
2122 | | - { |
2123 | | - "value": "2000", |
2124 | | - "type": "Number", |
2125 | | - "label": "Visibility distance", |
2126 | | - "name": "VisibilityDistanceMax" |
2127 | | - }, |
2128 | 2099 | { |
2129 | 2100 | "value": "Medium", |
2130 | 2101 | "type": "Choice", |
|
2177 | 2148 | { |
2178 | 2149 | "propertyName": "Decay" |
2179 | 2150 | }, |
2180 | | - { |
2181 | | - "propertyName": "VisibilityDistanceMax" |
2182 | | - }, |
2183 | 2151 | { |
2184 | 2152 | "folderName": "Cone", |
2185 | 2153 | "children": [ |
|
0 commit comments