Skip to content

Commit

Permalink
[3D sprite] Fix a crash when sprites have no frame (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H authored Oct 29, 2024
1 parent 4ae6201 commit 1ee81d3
Showing 1 changed file with 56 additions and 7 deletions.
63 changes: 56 additions & 7 deletions extensions/community/Sprite3D.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
"name": "Sprite3D",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/3bd33ec77ed20d3f631c6c92884728b375aa2879174bc9f289c864d0e0383d59_ghost-outline.svg",
"shortDescription": "An animated sprite in 3D.",
"version": "0.1.0",
"version": "0.1.1",
"description": "The 3D sprite is an object that can be moved and rotated in 3D.",
"origin": {
"identifier": "Sprite3D",
"name": "gdevelop-extension-store"
},
"tags": [
"3d"
],
"authorIds": [
"IWykYNRvhCZBN3vEgKEbBPOR3Oc2"
],
"dependencies": [],
"globalVariables": [],
"sceneVariables": [],
"eventsFunctions": [
{
"description": "Define helper classes JavaScript code.",
Expand Down Expand Up @@ -47,17 +53,21 @@
" ",
" const geometry = new THREE.PlaneGeometry(1, -1);",
" const animationFrame = object.getAnimator().getCurrentFrame();",
" const material = animationFrame.texture;",
" this.mesh = new THREE.Mesh(geometry, material);",
" this.mesh.rotation.order = 'ZYX';",
" object.get3DRendererObject().add(this.mesh);",
"",
" if (animationFrame) {",
" const material = animationFrame.texture;",
" this.mesh = new THREE.Mesh(geometry, material);",
" this.mesh.rotation.order = 'ZYX';",
" object.get3DRendererObject().add(this.mesh);",
" }",
" this.updateFrame();",
" object.getAnimator().setOnFrameChangeCallback(() => this.updateFrame());",
" }",
"",
" updateFrame() {",
" const frame = this.object.getAnimator().getCurrentFrame();",
" if (!frame) {",
" return;",
" }",
" const material = frame.texture;",
"",
" const image = material.map.image;",
Expand Down Expand Up @@ -134,11 +144,18 @@
"eventsBasedBehaviors": [],
"eventsBasedObjects": [
{
"areaMaxX": 64,
"areaMaxY": 64,
"areaMaxZ": 64,
"areaMinX": 0,
"areaMinY": 0,
"areaMinZ": 0,
"defaultName": "",
"description": "An animated sprite in 3D.",
"fullName": "3D sprite",
"is3D": true,
"isAnimatable": true,
"isUsingLegacyInstancesRenderer": true,
"name": "Sprite3D",
"eventsFunctions": [
{
Expand Down Expand Up @@ -192,7 +209,39 @@
"objects": [],
"objectsFolderStructure": {
"folderName": "__ROOT"
}
},
"objectsGroups": [],
"layers": [
{
"ambientLightColorB": 200,
"ambientLightColorG": 200,
"ambientLightColorR": 200,
"camera3DFarPlaneDistance": 10000,
"camera3DFieldOfView": 45,
"camera3DNearPlaneDistance": 3,
"cameraType": "",
"followBaseLayerCamera": false,
"isLightingLayer": false,
"isLocked": false,
"name": "",
"renderingType": "",
"visibility": true,
"cameras": [
{
"defaultSize": true,
"defaultViewport": true,
"height": 0,
"viewportBottom": 1,
"viewportLeft": 0,
"viewportRight": 1,
"viewportTop": 0,
"width": 0
}
],
"effects": []
}
],
"instances": []
}
]
}

0 comments on commit 1ee81d3

Please sign in to comment.