Skip to content

Commit 7ba14ad

Browse files
committed
Remove the distance property
1 parent 6101d0a commit 7ba14ad

1 file changed

Lines changed: 16 additions & 48 deletions

File tree

extensions/reviewed/SpotLight3D.json

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"}",
4242
"",
4343
"/**",
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",
4545
" */",
4646
"",
4747
"const game = runtimeScene.getGame();",
@@ -59,9 +59,9 @@
5959
" }",
6060
"",
6161
" _updateThreeGroup() {",
62-
" const object = this._object;",
63-
" /** @type {THREE.SpotLight} */",
62+
" /** @type {SpotLightRuntimeObject} */",
6463
" //@ts-ignore",
64+
" const object = this._object;",
6565
" const threeObject3D = this.get3DRendererObject();",
6666
"",
6767
" threeObject3D.rotation.set(",
@@ -85,8 +85,6 @@
8585
"",
8686
" threeObject3D.visible = !this._object.hidden;",
8787
"",
88-
" /** @type {THREE.SpotLight} */",
89-
" //@ts-ignore",
9088
" const spotLight = object.__spotLight;",
9189
"",
9290
" const editor = game.getInGameEditor ? game.getInGameEditor() : null;",
@@ -129,16 +127,10 @@
129127
" const deltaZ = rootObject.getZ() - cameraZ;",
130128
" distanceSq = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;",
131129
" }",
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);",
142134
" }",
143135
"",
144136
" // Force the visibility to be checked every frame",
@@ -263,17 +255,17 @@
263255
"const coneLength = 64;",
264256
"",
265257
"class SpotLightHelper extends THREE.Object3D {",
266-
" /** @type {gdjs.CustomRuntimeObject3D} */",
258+
" /** @type {SpotLightRuntimeObject} */",
267259
" object;",
268-
" /** @type {THREE.LineSegments} */",
260+
" /** @type {THREE.LineSegments<THREE.BufferGeometry, THREE.LineBasicMaterial>} */",
269261
" cone;",
270-
" /** @type {THREE.LineSegments} */",
262+
" /** @type {THREE.LineSegments<THREE.BufferGeometry, THREE.LineBasicMaterial>} */",
271263
" centerLine;",
272-
" /** @type {THREE.Mesh} */",
264+
" /** @type {THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>} */",
273265
" originBox;",
274266
"",
275267
"\t/**",
276-
" * @param {gdjs.CustomRuntimeObject3D} object",
268+
" * @param {SpotLightRuntimeObject} object",
277269
"\t */",
278270
" constructor(object) {",
279271
" super();",
@@ -325,38 +317,23 @@
325317
"",
326318
" dispose() {",
327319
" this.cone.geometry.dispose();",
328-
" //@ts-ignore",
329320
" this.cone.material.dispose();",
330321
" this.centerLine.geometry.dispose();",
331-
" //@ts-ignore",
332322
" this.centerLine.material.dispose();",
333323
" this.originBox.geometry.dispose();",
334-
" //@ts-ignore",
335324
" this.originBox.material.dispose();",
336325
" }",
337326
"",
338327
" update() {",
339328
" /** @type {number} */",
340-
" //@ts-ignore",
341329
" const coneAngle = gdjs.toRad(this.object._getConeAngle());",
342330
" const coneWidth = coneLength * Math.sin(coneAngle);",
343331
" const coneHeight = coneLength * Math.cos(coneAngle);",
344332
" 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);",
360337
" }",
361338
"}",
362339
"",
@@ -2119,12 +2096,6 @@
21192096
"group": "Shadow",
21202097
"name": "IsCastingShadow"
21212098
},
2122-
{
2123-
"value": "2000",
2124-
"type": "Number",
2125-
"label": "Visibility distance",
2126-
"name": "VisibilityDistanceMax"
2127-
},
21282099
{
21292100
"value": "Medium",
21302101
"type": "Choice",
@@ -2177,9 +2148,6 @@
21772148
{
21782149
"propertyName": "Decay"
21792150
},
2180-
{
2181-
"propertyName": "VisibilityDistanceMax"
2182-
},
21832151
{
21842152
"folderName": "Cone",
21852153
"children": [

0 commit comments

Comments
 (0)