Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions extensions/community/ProjectToCamera3D.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "ProjectToCamera3D",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/Maps and Navigation/5f308b28df69a05ce442f41f469dbeeae407726098ae481cbc58efb4f3514fe6_Maps and Navigation_location_pin_map.svg",
"shortDescription": "Move a 2D object to overlap a 3D position.",
"version": "1.0.0",
"version": "1.0.1",
"description": [
"It can be useful to:",
"- Display a gun sights in a 3rd person view",
Expand Down Expand Up @@ -78,9 +78,17 @@
" * @param {float} z",
" */",
"function moveToProjectedPoint(objects, layer3D, x, y, z) {",
" const threeCamera = layer3D.getRenderer().getThreeCamera();",
" if (objects.length === 0) {",
" return;",
" }",
" const scene = objects[0].getRuntimeScene();",
" const inverseWorldScale = scene.getRenderer3DInverseWorldScale ? scene.getRenderer3DInverseWorldScale() : 1;",
" const scaledX = x * inverseWorldScale;",
" const scaledY = -y * inverseWorldScale;",
" const scaledZ = z * inverseWorldScale;",
"",
" const isPointBehindCamera = vector.set(x, -y, z).sub(threeCamera.position).dot(threeCamera.getWorldDirection(cameraDirection)) < 0;",
" const threeCamera = layer3D.getRenderer().getThreeCamera();",
" const isPointBehindCamera = vector.set(scaledX, scaledY, scaledZ).sub(threeCamera.position).dot(threeCamera.getWorldDirection(cameraDirection)) < 0;",
" if (isPointBehindCamera) {",
" for (const object of objects) {",
" object.setPosition(-10000, -10000);",
Expand All @@ -90,7 +98,7 @@
"",
" const gameResolutionWidth = runtimeScene.getGame().getGameResolutionWidth();",
" const gameResolutionHeight = runtimeScene.getGame().getGameResolutionHeight();",
" vector.set(x, -y, z).project(threeCamera);",
" vector.set(scaledX, scaledY, scaledZ).project(threeCamera);",
" const projectedX = (gameResolutionWidth / 2) * (vector.x + 1);",
" const projectedY = (gameResolutionHeight / 2) * (1 - vector.y);",
"",
Expand Down
63 changes: 33 additions & 30 deletions extensions/reviewed/Light3D.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "Light3D",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/f237ae4e3b857c556846c7b2c0b132556fd4bcdeff217034b4d9c97dc1aab1d6_lightbulb-on-outline.svg",
"shortDescription": "A collection of light object for 3D.",
"version": "1.0.1",
"version": "1.0.2",
"description": "A collection of light object for 3D.",
"origin": {
"identifier": "Light3D",
Expand Down Expand Up @@ -162,10 +162,16 @@
" * @param targetZ {number}",
" */",
" lookAtPosition(targetX, targetY, targetZ) {",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
"",
" // Remove from the parent to avoid the scene scale of -1 on Y to mess with the formula.",
" const parent = this.spotLight.parent;",
" this.spotLight.parent = null;",
" this.spotLight.lookAt(targetX, targetY, targetZ);",
" this.spotLight.lookAt(",
" targetX * inverseWorldScale,",
" targetY * inverseWorldScale,",
" targetZ * inverseWorldScale);",
" this.spotLight.parent = parent;",
"",
" // Angle setters update Three.js angles, so we save them first.",
Expand Down Expand Up @@ -202,7 +208,9 @@
" * @param value {number}",
" */",
" setConeLength(value) {",
" this.spotLight.distance = value;",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
" this.spotLight.distance = value * inverseWorldScale;",
" }",
"",
" /**",
Expand Down Expand Up @@ -263,14 +271,18 @@
" * @param value {number}",
" */",
" setShadowCameraNearPlane(value) {",
" this.spotLight.shadow.camera.near = value;",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
" this.spotLight.shadow.camera.near = value * inverseWorldScale;",
" }",
"",
" /**",
" * @param value {number}",
" */",
" setShadowCameraFarPlane(value) {",
" this.spotLight.shadow.camera.far = value;",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
" this.spotLight.shadow.camera.far = value * inverseWorldScale;",
" }",
"",
" /**",
Expand All @@ -279,6 +291,8 @@
" * @param coneAngle {number}",
" */",
" setShadowBias(value, quality, coneAngle) {",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
" const biasMultiplier =",
" quality === 'Low'",
" ? 8",
Expand All @@ -288,7 +302,8 @@
" ? 2 : 1;",
" // Multiply by 0.125 to make values around 0.001 work best.",
" this.spotLight.shadow.bias = -value * 0.125 * biasMultiplier *",
" Math.tan(gdjs.toRad(gdjs.evtTools.common.clamp(coneAngle, 0, 89)));",
" Math.tan(gdjs.toRad(gdjs.evtTools.common.clamp(coneAngle, 0, 89))) *",
" inverseWorldScale;",
" }",
"",
" /**",
Expand Down Expand Up @@ -395,27 +410,6 @@
" }",
"",
" /**",
" * @param targetX {number}",
" * @param targetY {number}",
" * @param targetZ {number}",
" */",
" lookAtPosition(targetX, targetY, targetZ) {",
" // Remove from the parent to avoid the scene scale of -1 on Y to mess with the formula.",
" const parent = this.pointLight.parent;",
" this.pointLight.parent = null;",
" this.pointLight.lookAt(targetX, targetY, targetZ);",
" this.pointLight.parent = parent;",
"",
" // Angle setters update Three.js angles, so we save them first.",
" const rotationX = gdjs.toDegrees(this.pointLight.rotation.x);",
" const rotationY = gdjs.toDegrees(this.pointLight.rotation.y);",
" const rotationZ = gdjs.toDegrees(this.pointLight.rotation.z);",
" this.object.setRotationX(rotationX);",
" this.object.setRotationY(rotationY);",
" this.object.setAngle(rotationZ + 90);",
" }",
"",
" /**",
" * @param color {string}",
" */",
" setColor(color) {",
Expand Down Expand Up @@ -484,28 +478,37 @@
" * @param value {number}",
" */",
" setShadowCameraNearPlane(value) {",
" this.pointLight.shadow.camera.near = value;",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
"",
" this.pointLight.shadow.camera.near = value * inverseWorldScale;",
" }",
"",
" /**",
" * @param value {number}",
" */",
" setShadowCameraFarPlane(value) {",
" this.pointLight.shadow.camera.far = value;",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
"",
" this.pointLight.shadow.camera.far = value * inverseWorldScale;",
" }",
"",
" /**",
" * @param value {number}",
" * @param quality {\"Low\" | \"Medium\" | \"High\"}",
" */",
" setShadowBias(value, quality) {",
" const runtimeSene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeSene.getRenderer3DInverseWorldScale ? runtimeSene.getRenderer3DInverseWorldScale() : 1;",
"",
" const biasMultiplier =",
" quality === 'Low'",
" ? 4",
" : quality === 'Medium'",
" ? 2",
" : 1;",
" this.pointLight.shadow.bias = -value * biasMultiplier;",
" this.pointLight.shadow.bias = -value * biasMultiplier * inverseWorldScale;",
" }",
"}",
"",
Expand Down
Loading
Loading