Skip to content

Commit 0724a8a

Browse files
authored
[Community] [3D Sprite] Fix 3D sprites being rendered all black (#1577)
1 parent 6589f98 commit 0724a8a

File tree

1 file changed

+50
-40
lines changed

1 file changed

+50
-40
lines changed

extensions/community/Sprite3D.json

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"author": "",
33
"category": "General",
44
"extensionNamespace": "",
5-
"gdevelopVersion": ">=5.5.222",
65
"fullName": "3D sprite",
6+
"gdevelopVersion": ">=5.5.222",
77
"helpPath": "/objects/sprite/",
88
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWdob3N0LW91dGxpbmUiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIgMkM3LjAzIDIgMyA2LjAzIDMgMTFWMjJMNiAxOUw5IDIyTDEyIDE5TDE1IDIyTDE4IDE5TDIxIDIyVjExQzIxIDYuMDMgMTYuOTcgMiAxMiAyTTE5IDE3LjE3TDE4IDE2LjE3TDE2LjU5IDE3LjU5TDE1IDE5LjE3TDEzLjQxIDE3LjU5TDEyIDE2LjE3TDEwLjU5IDE3LjU5TDkgMTkuMTdMNy40MSAxNy41OUw2IDE2LjE3TDUgMTcuMTdWMTFDNSA3LjE0IDguMTQgNCAxMiA0UzE5IDcuMTQgMTkgMTFWMTcuMTdNMTEgMTBDMTEgMTEuMTEgMTAuMTEgMTIgOSAxMlM3IDExLjExIDcgMTAgNy45IDggOSA4IDExIDguOSAxMSAxME0xNyAxMEMxNyAxMS4xMSAxNi4xMSAxMiAxNSAxMlMxMyAxMS4xMSAxMyAxMCAxMy45IDggMTUgOCAxNyA4LjkgMTcgMTBaIiAvPjwvc3ZnPg==",
99
"name": "Sprite3D",
1010
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/3bd33ec77ed20d3f631c6c92884728b375aa2879174bc9f289c864d0e0383d59_ghost-outline.svg",
1111
"shortDescription": "An animated sprite in 3D.",
12-
"version": "0.1.1",
12+
"version": "0.1.2",
1313
"description": "The 3D sprite is an object that can be moved and rotated in 3D.",
1414
"origin": {
1515
"identifier": "Sprite3D",
@@ -40,6 +40,8 @@
4040
" return;",
4141
"}",
4242
"",
43+
"const vertexColors = [];",
44+
"",
4345
"class Sprite3DRenderer {",
4446
" /** @type {gdjs.CustomRuntimeObject} */",
4547
" object;",
@@ -51,14 +53,22 @@
5153
" */",
5254
" constructor(object) {",
5355
" this.object = object;",
54-
" ",
56+
"",
5557
" const geometry = new THREE.PlaneGeometry(1, -1);",
5658
" const animationFrame = object.getAnimator().getCurrentFrame();",
5759
" if (animationFrame) {",
5860
" const material = animationFrame.texture;",
5961
" this.mesh = new THREE.Mesh(geometry, material);",
6062
" this.mesh.rotation.order = 'ZYX';",
6163
" object.get3DRendererObject().add(this.mesh);",
64+
" // Ensure a forward compatibility when vertexColors will be set to true",
65+
" // in the engine to allow to tint 3D sprites.",
66+
" vertexColors.length = geometry.attributes.position.count * 3;",
67+
" vertexColors.fill(1);",
68+
" geometry.setAttribute(",
69+
" 'color',",
70+
" new THREE.BufferAttribute(new Float32Array(vertexColors), 3)",
71+
" );",
6272
" }",
6373
" this.updateFrame();",
6474
" object.getAnimator().setOnFrameChangeCallback(() => this.updateFrame());",
@@ -158,6 +168,42 @@
158168
"isAnimatable": true,
159169
"isUsingLegacyInstancesRenderer": true,
160170
"name": "Sprite3D",
171+
"objects": [],
172+
"objectsFolderStructure": {
173+
"folderName": "__ROOT"
174+
},
175+
"objectsGroups": [],
176+
"layers": [
177+
{
178+
"ambientLightColorB": 200,
179+
"ambientLightColorG": 200,
180+
"ambientLightColorR": 200,
181+
"camera3DFarPlaneDistance": 10000,
182+
"camera3DFieldOfView": 45,
183+
"camera3DNearPlaneDistance": 3,
184+
"cameraType": "",
185+
"followBaseLayerCamera": false,
186+
"isLightingLayer": false,
187+
"isLocked": false,
188+
"name": "",
189+
"renderingType": "",
190+
"visibility": true,
191+
"cameras": [
192+
{
193+
"defaultSize": true,
194+
"defaultViewport": true,
195+
"height": 0,
196+
"viewportBottom": 1,
197+
"viewportLeft": 0,
198+
"viewportRight": 1,
199+
"viewportTop": 0,
200+
"width": 0
201+
}
202+
],
203+
"effects": []
204+
}
205+
],
206+
"instances": [],
161207
"eventsFunctions": [
162208
{
163209
"fullName": "",
@@ -206,43 +252,7 @@
206252
"objectGroups": []
207253
}
208254
],
209-
"propertyDescriptors": [],
210-
"objects": [],
211-
"objectsFolderStructure": {
212-
"folderName": "__ROOT"
213-
},
214-
"objectsGroups": [],
215-
"layers": [
216-
{
217-
"ambientLightColorB": 200,
218-
"ambientLightColorG": 200,
219-
"ambientLightColorR": 200,
220-
"camera3DFarPlaneDistance": 10000,
221-
"camera3DFieldOfView": 45,
222-
"camera3DNearPlaneDistance": 3,
223-
"cameraType": "",
224-
"followBaseLayerCamera": false,
225-
"isLightingLayer": false,
226-
"isLocked": false,
227-
"name": "",
228-
"renderingType": "",
229-
"visibility": true,
230-
"cameras": [
231-
{
232-
"defaultSize": true,
233-
"defaultViewport": true,
234-
"height": 0,
235-
"viewportBottom": 1,
236-
"viewportLeft": 0,
237-
"viewportRight": 1,
238-
"viewportTop": 0,
239-
"width": 0
240-
}
241-
],
242-
"effects": []
243-
}
244-
],
245-
"instances": []
255+
"propertyDescriptors": []
246256
}
247257
]
248258
}

0 commit comments

Comments
 (0)