gdcore-tools 2.0.0-gd-v5.5.225-autobuild → 2.0.0-gd-v5.5.227-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +4 -4
- package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +4 -2
- package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(p){const x={3:0,2:1,5:2,4:3,0:4,1:5},M={0:3,1:2,2:5,3:4,4:0,5:1},n={0:[0,0],1:[1,0],2:[0,1],3:[1,1]},R={0:[0,1],1:[0,0],2:[1,1],3:[1,0]};let g;const _=()=>(g||(g=new THREE.MeshBasicMaterial({transparent:!0,opacity:0,alphaTest:1})),g),T=(h,i)=>h.isFaceAtIndexVisible(i)?h.getInstanceContainer().getGame().getImageManager().getThreeMaterial(h.getFaceAtIndexResourceName(i),{useTransparentTexture:h.shouldUseTransparentTexture(),forceBasicMaterial:h._materialType===p.Cube3DRuntimeObject.MaterialType.Basic,vertexColors:!0}):_();class f extends p.RuntimeObject3DRenderer{constructor(i,t){const o=new THREE.BoxGeometry(1,1,1),m=new Array(6).fill(0).map((e,d)=>T(i,M[d])),b=new THREE.Mesh(o,m);super(i,t,b);this._boxMesh=b,this._cube3DRuntimeObject=i,this.updateSize(),this.updatePosition(),this.updateRotation(),this.updateTint()}updateTint(){const i=[],t=p.rgbOrHexToRGBColor(this._cube3DRuntimeObject.getColor()).map(o=>o/255);for(let o=0;o<this._boxMesh.geometry.attributes.position.count;o++)i.push(...t);this._boxMesh.geometry.setAttribute("color",new THREE.BufferAttribute(new Float32Array(i),3))}updateFace(i){const t=x[i];t!==void 0&&(this._boxMesh.material[t]=T(this._cube3DRuntimeObject,i),this._cube3DRuntimeObject.isFaceAtIndexVisible(i)&&this.updateTextureUvMapping(i))}updateSize(){super.updateSize(),this.updateTextureUvMapping()}updateTextureUvMapping(i){const t=this._boxMesh.geometry.getAttribute("position"),o=this._boxMesh.geometry.getAttribute("uv"),m=i===void 0?0:x[i]*4,b=i===void 0?23:x[i]*4+3;for(let e=m;e<=b;e++){const d=Math.floor(e/4),r=this._boxMesh.material[d];if(!r||!r.map)continue;const c=this._cube3DRuntimeObject.shouldRepeatTextureOnFaceAtIndex(M[d]),u=this._cube3DRuntimeObject.getFacesOrientation()==="Y";let a,s;switch(d){case 0:c?u?(a=-(this._boxMesh.scale.z/r.map.source.data.width)*(t.getZ(e)-.5),s=-(this._boxMesh.scale.y/r.map.source.data.height)*(t.getY(e)+.5)):(a=-(this._boxMesh.scale.y/r.map.source.data.width)*(t.getY(e)-.5),s=this._boxMesh.scale.z/r.map.source.data.height*(t.getZ(e)-.5)):u?[a,s]=n[e%4]:[a,s]=R[e%4];break;case 1:c?u?(a=this._boxMesh.scale.z/r.map.source.data.width*(t.getZ(e)+.5),s=-(this._boxMesh.scale.y/r.map.source.data.height)*(t.getY(e)+.5)):(a=this._boxMesh.scale.y/r.map.source.data.width*(t.getY(e)+.5),s=this._boxMesh.scale.z/r.map.source.data.height*(t.getZ(e)-.5)):u?[a,s]=n[e%4]:([a,s]=R[e%4],a=-a,s=-s);break;case 2:c?(a=this._boxMesh.scale.x/r.map.source.data.width*(t.getX(e)+.5),s=this._boxMesh.scale.z/r.map.source.data.height*(t.getZ(e)-.5)):[a,s]=n[e%4];break;case 3:c?u?(a=this._boxMesh.scale.x/r.map.source.data.width*(t.getX(e)+.5),s=-(this._boxMesh.scale.z/r.map.source.data.height)*(t.getZ(e)+.5)):(a=-(this._boxMesh.scale.x/r.map.source.data.width)*(t.getX(e)-.5),s=this._boxMesh.scale.z/r.map.source.data.height*(t.getZ(e)-.5)):([a,s]=n[e%4],u||(a=-a,s=-s));break;case 4:c?(a=this._boxMesh.scale.x/r.map.source.data.width*(t.getX(e)+.5),s=-(this._boxMesh.scale.y/r.map.source.data.height)*(t.getY(e)+.5)):[a,s]=n[e%4];break;case 5:const l=this._cube3DRuntimeObject.getBackFaceUpThroughWhichAxisRotation()==="X";c?(a=(l?1:-1)*(this._boxMesh.scale.x/r.map.source.data.width)*(t.getX(e)+(l?1:-1)*.5),s=(l?1:-1)*(this._boxMesh.scale.y/r.map.source.data.height)*(t.getY(e)+(l?-1:1)*.5)):([a,s]=n[e%4],l&&(a=-a,s=-s));break;default:[a,s]=n[e%4]}o.setXY(e,a,s)}o.needsUpdate=!0}_updateMaterials(){for(let i=0;i<6;i++)this.updateFace(i)}}p.Cube3DRuntimeObjectRenderer=f})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=Cube3DRuntimeObjectPixiRenderer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n // Three.js materials for a cube and the order of faces in the object is different,\n // so we keep the mapping from one to the other.\n const faceIndexToMaterialIndex = {\n 3: 0, // right\n 2: 1, // left\n 5: 2, // bottom\n 4: 3, // top\n 0: 4, // front\n 1: 5, // back\n };\n const materialIndexToFaceIndex = {\n 0: 3,\n 1: 2,\n 2: 5,\n 3: 4,\n 4: 0,\n 5: 1,\n };\n\n const noRepeatTextureVertexIndexToUvMapping = {\n 0: [0, 0],\n 1: [1, 0],\n 2: [0, 1],\n 3: [1, 1],\n };\n\n const noRepeatTextureVertexIndexToUvMappingForLeftAndRightFacesTowardsZ = {\n 0: [0, 1],\n 1: [0, 0],\n 2: [1, 1],\n 3: [1, 0],\n };\n\n let transparentMaterial: THREE.MeshBasicMaterial;\n const getTransparentMaterial = () => {\n if (!transparentMaterial)\n transparentMaterial = new THREE.MeshBasicMaterial({\n transparent: true,\n opacity: 0,\n // Set the alpha test to to ensure the faces behind are rendered\n // (no \"back face culling\" that would still be done if alphaTest is not set).\n alphaTest: 1,\n });\n\n return transparentMaterial;\n };\n\n const getFaceMaterial = (\n runtimeObject: gdjs.Cube3DRuntimeObject,\n faceIndex: integer\n ) => {\n if (!runtimeObject.isFaceAtIndexVisible(faceIndex))\n return getTransparentMaterial();\n\n return runtimeObject\n .getInstanceContainer()\n .getGame()\n .getImageManager()\n .getThreeMaterial(runtimeObject.getFaceAtIndexResourceName(faceIndex), {\n useTransparentTexture: runtimeObject.shouldUseTransparentTexture(),\n forceBasicMaterial:\n runtimeObject._materialType ===\n gdjs.Cube3DRuntimeObject.MaterialType.Basic,\n });\n };\n\n class Cube3DRuntimeObjectPixiRenderer extends gdjs.RuntimeObject3DRenderer {\n private _cube3DRuntimeObject: gdjs.Cube3DRuntimeObject;\n private _boxMesh: THREE.Mesh;\n\n constructor(\n runtimeObject: gdjs.Cube3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n const geometry = new THREE.BoxGeometry(1, 1, 1);\n\n const materials: THREE.Material[] = new Array(6)\n .fill(0)\n .map((_, index) =>\n getFaceMaterial(runtimeObject, materialIndexToFaceIndex[index])\n );\n\n const boxMesh = new THREE.Mesh(geometry, materials);\n\n super(runtimeObject, instanceContainer, boxMesh);\n this._boxMesh = boxMesh;\n this._cube3DRuntimeObject = runtimeObject;\n\n this.updateSize();\n this.updatePosition();\n this.updateRotation();\n this.updateTint();\n }\n\n updateTint() {\n const tints: number[] = [];\n\n const normalizedTint = gdjs\n .rgbOrHexToRGBColor(this._cube3DRuntimeObject.getColor())\n .map((component) => component / 255);\n\n for (\n let i = 0;\n i < this._boxMesh.geometry.attributes.position.count;\n i++\n ) {\n tints.push(...normalizedTint);\n }\n\n this._boxMesh.geometry.setAttribute(\n 'color',\n new THREE.BufferAttribute(new Float32Array(tints), 3)\n );\n }\n\n updateFace(faceIndex: integer) {\n const materialIndex = faceIndexToMaterialIndex[faceIndex];\n if (materialIndex === undefined) return;\n\n this._boxMesh.material[materialIndex] = getFaceMaterial(\n this._cube3DRuntimeObject,\n faceIndex\n );\n if (this._cube3DRuntimeObject.isFaceAtIndexVisible(faceIndex)) {\n this.updateTextureUvMapping(faceIndex);\n }\n }\n\n updateSize(): void {\n super.updateSize();\n this.updateTextureUvMapping();\n }\n\n /**\n * Updates the UV mapping of the geometry in order to repeat a material\n * over the different faces of the cube.\n * The mesh must be configured with a list of materials in order\n * for the method to work.\n * @param faceIndex The face index to update. If undefined, updates all the faces.\n */\n updateTextureUvMapping(faceIndex?: number) {\n // @ts-ignore - position is stored as a Float32BufferAttribute\n const pos: THREE.BufferAttribute =\n this._boxMesh.geometry.getAttribute('position');\n // @ts-ignore - uv is stored as a Float32BufferAttribute\n const uvMapping: THREE.BufferAttribute =\n this._boxMesh.geometry.getAttribute('uv');\n const startIndex =\n faceIndex === undefined ? 0 : faceIndexToMaterialIndex[faceIndex] * 4;\n const endIndex =\n faceIndex === undefined\n ? 23\n : faceIndexToMaterialIndex[faceIndex] * 4 + 3;\n for (\n let vertexIndex = startIndex;\n vertexIndex <= endIndex;\n vertexIndex++\n ) {\n const materialIndex = Math.floor(\n vertexIndex /\n // Each face of the cube has 4 points\n 4\n );\n const material = this._boxMesh.material[materialIndex];\n if (!material || !material.map) {\n continue;\n }\n\n const shouldRepeatTexture =\n this._cube3DRuntimeObject.shouldRepeatTextureOnFaceAtIndex(\n materialIndexToFaceIndex[materialIndex]\n );\n\n const shouldOrientateFacesTowardsY =\n this._cube3DRuntimeObject.getFacesOrientation() === 'Y';\n\n let x: float, y: float;\n switch (materialIndex) {\n case 0:\n // Right face\n if (shouldRepeatTexture) {\n if (shouldOrientateFacesTowardsY) {\n x =\n -(this._boxMesh.scale.z / material.map.source.data.width) *\n (pos.getZ(vertexIndex) - 0.5);\n y =\n -(this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) + 0.5);\n } else {\n x =\n -(this._boxMesh.scale.y / material.map.source.data.width) *\n (pos.getY(vertexIndex) - 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n }\n } else {\n if (shouldOrientateFacesTowardsY) {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n } else {\n [x, y] =\n noRepeatTextureVertexIndexToUvMappingForLeftAndRightFacesTowardsZ[\n vertexIndex % 4\n ];\n }\n }\n break;\n case 1:\n // Left face\n if (shouldRepeatTexture) {\n if (shouldOrientateFacesTowardsY) {\n x =\n (this._boxMesh.scale.z / material.map.source.data.width) *\n (pos.getZ(vertexIndex) + 0.5);\n y =\n -(this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) + 0.5);\n } else {\n x =\n (this._boxMesh.scale.y / material.map.source.data.width) *\n (pos.getY(vertexIndex) + 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n }\n } else {\n if (shouldOrientateFacesTowardsY) {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n } else {\n [x, y] =\n noRepeatTextureVertexIndexToUvMappingForLeftAndRightFacesTowardsZ[\n vertexIndex % 4\n ];\n x = -x;\n y = -y;\n }\n }\n break;\n case 2:\n // Bottom face\n if (shouldRepeatTexture) {\n x =\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) + 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n }\n break;\n case 3:\n // Top face\n if (shouldRepeatTexture) {\n if (shouldOrientateFacesTowardsY) {\n x =\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) + 0.5);\n y =\n -(this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) + 0.5);\n } else {\n x =\n -(this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) - 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n }\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n if (!shouldOrientateFacesTowardsY) {\n x = -x;\n y = -y;\n }\n }\n break;\n case 4:\n // Front face\n if (shouldRepeatTexture) {\n x =\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) + 0.5);\n y =\n -(this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) + 0.5);\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n }\n break;\n case 5:\n // Back face\n const shouldBackFaceBeUpThroughXAxisRotation =\n this._cube3DRuntimeObject.getBackFaceUpThroughWhichAxisRotation() ===\n 'X';\n\n if (shouldRepeatTexture) {\n x =\n (shouldBackFaceBeUpThroughXAxisRotation ? 1 : -1) *\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) +\n (shouldBackFaceBeUpThroughXAxisRotation ? 1 : -1) * 0.5);\n y =\n (shouldBackFaceBeUpThroughXAxisRotation ? 1 : -1) *\n (this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) +\n (shouldBackFaceBeUpThroughXAxisRotation ? -1 : 1) * 0.5);\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n if (shouldBackFaceBeUpThroughXAxisRotation) {\n x = -x;\n y = -y;\n }\n }\n break;\n default:\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n }\n uvMapping.setXY(vertexIndex, x, y);\n }\n uvMapping.needsUpdate = true;\n }\n\n _updateMaterials() {\n for (let index = 0; index < 6; index++) {\n this.updateFace(index);\n }\n }\n }\n\n export const Cube3DRuntimeObjectRenderer = Cube3DRuntimeObjectPixiRenderer;\n export type Cube3DRuntimeObjectRenderer = Cube3DRuntimeObjectPixiRenderer;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAGE,KAAM,GAA2B,CAC/B,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,GAEC,EAA2B,CAC/B,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,GAGC,EAAwC,CAC5C,EAAG,CAAC,EAAG,GACP,EAAG,CAAC,EAAG,GACP,EAAG,CAAC,EAAG,GACP,EAAG,CAAC,EAAG,IAGH,EAAoE,CACxE,EAAG,CAAC,EAAG,GACP,EAAG,CAAC,EAAG,GACP,EAAG,CAAC,EAAG,GACP,EAAG,CAAC,EAAG,IAGT,GAAI,GACJ,KAAM,GAAyB,IACxB,IACH,GAAsB,GAAI,OAAM,kBAAkB,CAChD,YAAa,GACb,QAAS,EAGT,UAAW,KAGR,GAGH,EAAkB,CACtB,EACA,IAEK,EAAc,qBAAqB,GAGjC,EACJ,uBACA,UACA,kBACA,iBAAiB,EAAc,2BAA2B,GAAY,CACrE,sBAAuB,EAAc,8BACrC,mBACE,EAAc,gBACd,EAAK,oBAAoB,aAAa,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n // Three.js materials for a cube and the order of faces in the object is different,\n // so we keep the mapping from one to the other.\n const faceIndexToMaterialIndex = {\n 3: 0, // right\n 2: 1, // left\n 5: 2, // bottom\n 4: 3, // top\n 0: 4, // front\n 1: 5, // back\n };\n const materialIndexToFaceIndex = {\n 0: 3,\n 1: 2,\n 2: 5,\n 3: 4,\n 4: 0,\n 5: 1,\n };\n\n const noRepeatTextureVertexIndexToUvMapping = {\n 0: [0, 0],\n 1: [1, 0],\n 2: [0, 1],\n 3: [1, 1],\n };\n\n const noRepeatTextureVertexIndexToUvMappingForLeftAndRightFacesTowardsZ = {\n 0: [0, 1],\n 1: [0, 0],\n 2: [1, 1],\n 3: [1, 0],\n };\n\n let transparentMaterial: THREE.MeshBasicMaterial;\n const getTransparentMaterial = () => {\n if (!transparentMaterial)\n transparentMaterial = new THREE.MeshBasicMaterial({\n transparent: true,\n opacity: 0,\n // Set the alpha test to to ensure the faces behind are rendered\n // (no \"back face culling\" that would still be done if alphaTest is not set).\n alphaTest: 1,\n });\n\n return transparentMaterial;\n };\n\n const getFaceMaterial = (\n runtimeObject: gdjs.Cube3DRuntimeObject,\n faceIndex: integer\n ) => {\n if (!runtimeObject.isFaceAtIndexVisible(faceIndex))\n return getTransparentMaterial();\n\n return runtimeObject\n .getInstanceContainer()\n .getGame()\n .getImageManager()\n .getThreeMaterial(runtimeObject.getFaceAtIndexResourceName(faceIndex), {\n useTransparentTexture: runtimeObject.shouldUseTransparentTexture(),\n forceBasicMaterial:\n runtimeObject._materialType ===\n gdjs.Cube3DRuntimeObject.MaterialType.Basic,\n vertexColors: true,\n });\n };\n\n class Cube3DRuntimeObjectPixiRenderer extends gdjs.RuntimeObject3DRenderer {\n private _cube3DRuntimeObject: gdjs.Cube3DRuntimeObject;\n private _boxMesh: THREE.Mesh;\n\n constructor(\n runtimeObject: gdjs.Cube3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n const geometry = new THREE.BoxGeometry(1, 1, 1);\n\n const materials: THREE.Material[] = new Array(6)\n .fill(0)\n .map((_, index) =>\n getFaceMaterial(runtimeObject, materialIndexToFaceIndex[index])\n );\n\n const boxMesh = new THREE.Mesh(geometry, materials);\n\n super(runtimeObject, instanceContainer, boxMesh);\n this._boxMesh = boxMesh;\n this._cube3DRuntimeObject = runtimeObject;\n\n this.updateSize();\n this.updatePosition();\n this.updateRotation();\n this.updateTint();\n }\n\n updateTint() {\n const tints: number[] = [];\n\n const normalizedTint = gdjs\n .rgbOrHexToRGBColor(this._cube3DRuntimeObject.getColor())\n .map((component) => component / 255);\n\n for (\n let i = 0;\n i < this._boxMesh.geometry.attributes.position.count;\n i++\n ) {\n tints.push(...normalizedTint);\n }\n\n this._boxMesh.geometry.setAttribute(\n 'color',\n new THREE.BufferAttribute(new Float32Array(tints), 3)\n );\n }\n\n updateFace(faceIndex: integer) {\n const materialIndex = faceIndexToMaterialIndex[faceIndex];\n if (materialIndex === undefined) return;\n\n this._boxMesh.material[materialIndex] = getFaceMaterial(\n this._cube3DRuntimeObject,\n faceIndex\n );\n if (this._cube3DRuntimeObject.isFaceAtIndexVisible(faceIndex)) {\n this.updateTextureUvMapping(faceIndex);\n }\n }\n\n updateSize(): void {\n super.updateSize();\n this.updateTextureUvMapping();\n }\n\n /**\n * Updates the UV mapping of the geometry in order to repeat a material\n * over the different faces of the cube.\n * The mesh must be configured with a list of materials in order\n * for the method to work.\n * @param faceIndex The face index to update. If undefined, updates all the faces.\n */\n updateTextureUvMapping(faceIndex?: number) {\n // @ts-ignore - position is stored as a Float32BufferAttribute\n const pos: THREE.BufferAttribute =\n this._boxMesh.geometry.getAttribute('position');\n // @ts-ignore - uv is stored as a Float32BufferAttribute\n const uvMapping: THREE.BufferAttribute =\n this._boxMesh.geometry.getAttribute('uv');\n const startIndex =\n faceIndex === undefined ? 0 : faceIndexToMaterialIndex[faceIndex] * 4;\n const endIndex =\n faceIndex === undefined\n ? 23\n : faceIndexToMaterialIndex[faceIndex] * 4 + 3;\n for (\n let vertexIndex = startIndex;\n vertexIndex <= endIndex;\n vertexIndex++\n ) {\n const materialIndex = Math.floor(\n vertexIndex /\n // Each face of the cube has 4 points\n 4\n );\n const material = this._boxMesh.material[materialIndex];\n if (!material || !material.map) {\n continue;\n }\n\n const shouldRepeatTexture =\n this._cube3DRuntimeObject.shouldRepeatTextureOnFaceAtIndex(\n materialIndexToFaceIndex[materialIndex]\n );\n\n const shouldOrientateFacesTowardsY =\n this._cube3DRuntimeObject.getFacesOrientation() === 'Y';\n\n let x: float, y: float;\n switch (materialIndex) {\n case 0:\n // Right face\n if (shouldRepeatTexture) {\n if (shouldOrientateFacesTowardsY) {\n x =\n -(this._boxMesh.scale.z / material.map.source.data.width) *\n (pos.getZ(vertexIndex) - 0.5);\n y =\n -(this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) + 0.5);\n } else {\n x =\n -(this._boxMesh.scale.y / material.map.source.data.width) *\n (pos.getY(vertexIndex) - 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n }\n } else {\n if (shouldOrientateFacesTowardsY) {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n } else {\n [x, y] =\n noRepeatTextureVertexIndexToUvMappingForLeftAndRightFacesTowardsZ[\n vertexIndex % 4\n ];\n }\n }\n break;\n case 1:\n // Left face\n if (shouldRepeatTexture) {\n if (shouldOrientateFacesTowardsY) {\n x =\n (this._boxMesh.scale.z / material.map.source.data.width) *\n (pos.getZ(vertexIndex) + 0.5);\n y =\n -(this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) + 0.5);\n } else {\n x =\n (this._boxMesh.scale.y / material.map.source.data.width) *\n (pos.getY(vertexIndex) + 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n }\n } else {\n if (shouldOrientateFacesTowardsY) {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n } else {\n [x, y] =\n noRepeatTextureVertexIndexToUvMappingForLeftAndRightFacesTowardsZ[\n vertexIndex % 4\n ];\n x = -x;\n y = -y;\n }\n }\n break;\n case 2:\n // Bottom face\n if (shouldRepeatTexture) {\n x =\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) + 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n }\n break;\n case 3:\n // Top face\n if (shouldRepeatTexture) {\n if (shouldOrientateFacesTowardsY) {\n x =\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) + 0.5);\n y =\n -(this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) + 0.5);\n } else {\n x =\n -(this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) - 0.5);\n y =\n (this._boxMesh.scale.z / material.map.source.data.height) *\n (pos.getZ(vertexIndex) - 0.5);\n }\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n if (!shouldOrientateFacesTowardsY) {\n x = -x;\n y = -y;\n }\n }\n break;\n case 4:\n // Front face\n if (shouldRepeatTexture) {\n x =\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) + 0.5);\n y =\n -(this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) + 0.5);\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n }\n break;\n case 5:\n // Back face\n const shouldBackFaceBeUpThroughXAxisRotation =\n this._cube3DRuntimeObject.getBackFaceUpThroughWhichAxisRotation() ===\n 'X';\n\n if (shouldRepeatTexture) {\n x =\n (shouldBackFaceBeUpThroughXAxisRotation ? 1 : -1) *\n (this._boxMesh.scale.x / material.map.source.data.width) *\n (pos.getX(vertexIndex) +\n (shouldBackFaceBeUpThroughXAxisRotation ? 1 : -1) * 0.5);\n y =\n (shouldBackFaceBeUpThroughXAxisRotation ? 1 : -1) *\n (this._boxMesh.scale.y / material.map.source.data.height) *\n (pos.getY(vertexIndex) +\n (shouldBackFaceBeUpThroughXAxisRotation ? -1 : 1) * 0.5);\n } else {\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n if (shouldBackFaceBeUpThroughXAxisRotation) {\n x = -x;\n y = -y;\n }\n }\n break;\n default:\n [x, y] = noRepeatTextureVertexIndexToUvMapping[vertexIndex % 4];\n }\n uvMapping.setXY(vertexIndex, x, y);\n }\n uvMapping.needsUpdate = true;\n }\n\n _updateMaterials() {\n for (let index = 0; index < 6; index++) {\n this.updateFace(index);\n }\n }\n }\n\n export const Cube3DRuntimeObjectRenderer = Cube3DRuntimeObjectPixiRenderer;\n export type Cube3DRuntimeObjectRenderer = Cube3DRuntimeObjectPixiRenderer;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAGE,KAAM,GAA2B,CAC/B,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,GAEC,EAA2B,CAC/B,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,GAGC,EAAwC,CAC5C,EAAG,CAAC,EAAG,GACP,EAAG,CAAC,EA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SAAS,MAAM,EAAI,EAAS,IAAI,OAAO,KAAK,OACjD,GAAI,KAAK,GACP,GAAyC,EAAI,IAAM,IACxD,EACG,GAAyC,EAAI,IAC7C,MAAK,SAAS,MAAM,EAAI,EAAS,IAAI,OAAO,KAAK,QACjD,GAAI,KAAK,GACP,GAAyC,GAAK,GAAK,KAExD,EAAC,EAAG,GAAK,EAAsC,EAAc,GACzD,GACF,GAAI,CAAC,EACL,EAAI,CAAC,IAGT,cAEA,CAAC,EAAG,GAAK,EAAsC,EAAc,GAEjE,EAAU,MAAM,EAAa,EAAG,GAElC,EAAU,YAAc,GAG1B,kBAAmB,CACjB,OAAS,GAAQ,EAAG,EAAQ,EAAG,IAC7B,KAAK,WAAW,IAKf,AAAM,8BAA8B,IA5UnC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(a){class u{constructor(e,t,i){this._isContainerDirty=!0;this._object=e,this._instanceContainer=t,this._threeGroup=new THREE.Group,this._threeGroup.rotation.order="ZYX";const r=i.getLayer("");r&&r.getRenderer().add3DRendererObject(this._threeGroup)}get3DRendererObject(){return this._threeGroup}getRendererObject(){return null}reinitialize(e,t){this._object=e,this._isContainerDirty=!0;const i=t.getLayer("");i&&i.getRenderer().add3DRendererObject(this._threeGroup)}_updateThreeGroup(){const e=this.get3DRendererObject(),t=this._object.getScaleX(),i=this._object.getScaleY(),r=this._object.getScaleZ(),n=this._object.getUnscaledCenterX()*t,s=this._object.getUnscaledCenterY()*i,o=this._object.getUnscaledCenterZ()*r;e.rotation.set(a.toRad(this._object.getRotationX()),a.toRad(this._object.getRotationY()),a.toRad(this._object.angle)),e.position.set(this._object.isFlippedX()?n:-n,this._object.isFlippedY()?s:-s,this._object.isFlippedZ()?o:-o),e.position.applyEuler(e.rotation),e.position.x+=this._object.getX()+n,e.position.y+=this._object.getY()+s,e.position.z+=this._object.getZ()+o,e.scale.set(this._object.isFlippedX()?-t:t,this._object.isFlippedY()?-i:i,this._object.isFlippedZ()?-r:r),e.visible=!this._object.hidden,this._isContainerDirty=!1}ensureUpToDate(){this._isContainerDirty&&this._updateThreeGroup()}update(){this._isContainerDirty=!0}updateX(){this._isContainerDirty=!0}updateY(){this._isContainerDirty=!0}updateAngle(){this._isContainerDirty=!0}updatePosition(){this._isContainerDirty=!0}updateRotation(){this._isContainerDirty=!0}updateSize(){this._isContainerDirty=!0}updateVisibility(){this._threeGroup.visible=!this._object.hidden}updateOpacity(){}setLayerIndex(e,t){}static getAnimationFrameTextureManager(e){return e._threeAnimationFrameTextureManager||(e._threeAnimationFrameTextureManager=new c(e)),e._threeAnimationFrameTextureManager}}a.CustomRuntimeObject3DRenderer=u;class c{constructor(e){this._imageManager=e}getAnimationFrameTexture(e){return this._imageManager.getThreeMaterial(e,{useTransparentTexture:!0,forceBasicMaterial:!0})}getAnimationFrameWidth(e){const t=e.map;return t?t.image.width:0}getAnimationFrameHeight(e){const t=e.map;return t?t.image.height:0}}})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(a){class u{constructor(e,t,i){this._isContainerDirty=!0;this._object=e,this._instanceContainer=t,this._threeGroup=new THREE.Group,this._threeGroup.rotation.order="ZYX";const r=i.getLayer("");r&&r.getRenderer().add3DRendererObject(this._threeGroup)}get3DRendererObject(){return this._threeGroup}getRendererObject(){return null}reinitialize(e,t){this._object=e,this._isContainerDirty=!0;const i=t.getLayer("");i&&i.getRenderer().add3DRendererObject(this._threeGroup)}_updateThreeGroup(){const e=this.get3DRendererObject(),t=this._object.getScaleX(),i=this._object.getScaleY(),r=this._object.getScaleZ(),n=this._object.getUnscaledCenterX()*t,s=this._object.getUnscaledCenterY()*i,o=this._object.getUnscaledCenterZ()*r;e.rotation.set(a.toRad(this._object.getRotationX()),a.toRad(this._object.getRotationY()),a.toRad(this._object.angle)),e.position.set(this._object.isFlippedX()?n:-n,this._object.isFlippedY()?s:-s,this._object.isFlippedZ()?o:-o),e.position.applyEuler(e.rotation),e.position.x+=this._object.getX()+n,e.position.y+=this._object.getY()+s,e.position.z+=this._object.getZ()+o,e.scale.set(this._object.isFlippedX()?-t:t,this._object.isFlippedY()?-i:i,this._object.isFlippedZ()?-r:r),e.visible=!this._object.hidden,this._isContainerDirty=!1}ensureUpToDate(){this._isContainerDirty&&this._updateThreeGroup()}update(){this._isContainerDirty=!0}updateX(){this._isContainerDirty=!0}updateY(){this._isContainerDirty=!0}updateAngle(){this._isContainerDirty=!0}updatePosition(){this._isContainerDirty=!0}updateRotation(){this._isContainerDirty=!0}updateSize(){this._isContainerDirty=!0}updateVisibility(){this._threeGroup.visible=!this._object.hidden}updateOpacity(){}setLayerIndex(e,t){}static getAnimationFrameTextureManager(e){return e._threeAnimationFrameTextureManager||(e._threeAnimationFrameTextureManager=new c(e)),e._threeAnimationFrameTextureManager}}a.CustomRuntimeObject3DRenderer=u;class c{constructor(e){this._imageManager=e}getAnimationFrameTexture(e){return this._imageManager.getThreeMaterial(e,{useTransparentTexture:!0,forceBasicMaterial:!0,vertexColors:!1})}getAnimationFrameWidth(e){const t=e.map;return t?t.image.width:0}getAnimationFrameHeight(e){const t=e.map;return t?t.image.height:0}}})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=CustomRuntimeObject3DRenderer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/CustomRuntimeObject3DRenderer.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n export interface PixiImageManager {\n _threeAnimationFrameTextureManager: ThreeAnimationFrameTextureManager;\n }\n /**\n * The renderer for a {@link gdjs.CustomRuntimeObject3D} using Three.js.\n */\n export class CustomRuntimeObject3DRenderer\n implements gdjs.RuntimeInstanceContainerRenderer\n {\n _object: gdjs.CustomRuntimeObject3D;\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _isContainerDirty: boolean = true;\n _threeGroup: THREE.Group;\n\n constructor(\n object: gdjs.CustomRuntimeObject3D,\n instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._instanceContainer = instanceContainer;\n\n this._threeGroup = new THREE.Group();\n this._threeGroup.rotation.order = 'ZYX';\n\n const layer = parent.getLayer('');\n if (layer) {\n layer.getRenderer().add3DRendererObject(this._threeGroup);\n }\n }\n\n get3DRendererObject(): THREE.Object3D {\n return this._threeGroup;\n }\n\n getRendererObject() {\n return null;\n }\n\n reinitialize(\n object: gdjs.CustomRuntimeObject3D,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._isContainerDirty = true;\n const layer = parent.getLayer('');\n if (layer) {\n layer.getRenderer().add3DRendererObject(this._threeGroup);\n }\n }\n\n _updateThreeGroup() {\n const threeObject3D = this.get3DRendererObject();\n\n const scaleX = this._object.getScaleX();\n const scaleY = this._object.getScaleY();\n const scaleZ = this._object.getScaleZ();\n const pivotX = this._object.getUnscaledCenterX() * scaleX;\n const pivotY = this._object.getUnscaledCenterY() * scaleY;\n const pivotZ = this._object.getUnscaledCenterZ() * scaleZ;\n\n threeObject3D.rotation.set(\n gdjs.toRad(this._object.getRotationX()),\n gdjs.toRad(this._object.getRotationY()),\n gdjs.toRad(this._object.angle)\n );\n\n threeObject3D.position.set(\n this._object.isFlippedX() ? pivotX : -pivotX,\n this._object.isFlippedY() ? pivotY : -pivotY,\n this._object.isFlippedZ() ? pivotZ : -pivotZ\n );\n threeObject3D.position.applyEuler(threeObject3D.rotation);\n threeObject3D.position.x += this._object.getX() + pivotX;\n threeObject3D.position.y += this._object.getY() + pivotY;\n threeObject3D.position.z += this._object.getZ() + pivotZ;\n\n threeObject3D.scale.set(\n this._object.isFlippedX() ? -scaleX : scaleX,\n this._object.isFlippedY() ? -scaleY : scaleY,\n this._object.isFlippedZ() ? -scaleZ : scaleZ\n );\n\n threeObject3D.visible = !this._object.hidden;\n\n this._isContainerDirty = false;\n }\n\n /**\n * Call this to make sure the object is ready to be rendered.\n */\n ensureUpToDate() {\n if (this._isContainerDirty) {\n this._updateThreeGroup();\n }\n }\n\n update(): void {\n this._isContainerDirty = true;\n }\n\n updateX(): void {\n this._isContainerDirty = true;\n }\n\n updateY(): void {\n this._isContainerDirty = true;\n }\n\n updateAngle(): void {\n this._isContainerDirty = true;\n }\n\n updatePosition() {\n this._isContainerDirty = true;\n }\n\n updateRotation() {\n this._isContainerDirty = true;\n }\n\n updateSize() {\n this._isContainerDirty = true;\n }\n\n updateVisibility(): void {\n this._threeGroup.visible = !this._object.hidden;\n }\n\n updateOpacity(): void {\n // Opacity is not handled by 3D custom objects.\n }\n\n setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {\n // Layers are not handled for 3D custom objects.\n }\n\n static getAnimationFrameTextureManager(\n imageManager: gdjs.PixiImageManager\n ): ThreeAnimationFrameTextureManager {\n if (!imageManager._threeAnimationFrameTextureManager) {\n imageManager._threeAnimationFrameTextureManager =\n new ThreeAnimationFrameTextureManager(imageManager);\n }\n return imageManager._threeAnimationFrameTextureManager;\n }\n }\n\n class ThreeAnimationFrameTextureManager\n implements gdjs.AnimationFrameTextureManager<THREE.Material>\n {\n private _imageManager: gdjs.PixiImageManager;\n\n constructor(imageManager: gdjs.PixiImageManager) {\n this._imageManager = imageManager;\n }\n\n getAnimationFrameTexture(imageName: string) {\n return this._imageManager.getThreeMaterial(imageName, {\n useTransparentTexture: true,\n forceBasicMaterial: true,\n });\n }\n\n getAnimationFrameWidth(material: THREE.Material) {\n const map = (\n material as THREE.MeshBasicMaterial | THREE.MeshStandardMaterial\n ).map;\n return map ? map.image.width : 0;\n }\n\n getAnimationFrameHeight(material: THREE.Material) {\n const map = (\n material as THREE.MeshBasicMaterial | THREE.MeshStandardMaterial\n ).map;\n return map ? map.image.height : 0;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAOS,OAEP,CAME,YACE,EACA,E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,AAAI,KAAK,mBACP,KAAK,oBAIT,QAAe,CACb,KAAK,kBAAoB,GAG3B,SAAgB,CACd,KAAK,kBAAoB,GAG3B,SAAgB,CACd,KAAK,kBAAoB,GAG3B,aAAoB,CAClB,KAAK,kBAAoB,GAG3B,gBAAiB,CACf,KAAK,kBAAoB,GAG3B,gBAAiB,CACf,KAAK,kBAAoB,GAG3B,YAAa,CACX,KAAK,kBAAoB,GAG3B,kBAAyB,CACvB,KAAK,YAAY,QAAU,CAAC,KAAK,QAAQ,OAG3C,eAAsB,EAItB,cAAc,EAA0B,EAAoB,QAIrD,iCACL,EACmC,CACnC,MAAK,GAAa,oCAChB,GAAa,mCACX,GAAI,GAAkC,IAEnC,EAAa,oCA1IjB,EAAM,gCA8Ib,OAEA,CAGE,YAAY,EAAqC,CAC/C,KAAK,cAAgB,EAGvB,yBAAyB,EAAmB,CAC1C,MAAO,MAAK,cAAc,iBAAiB,EAAW,CACpD,sBAAuB,GACvB,mBAAoB,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n export interface PixiImageManager {\n _threeAnimationFrameTextureManager: ThreeAnimationFrameTextureManager;\n }\n /**\n * The renderer for a {@link gdjs.CustomRuntimeObject3D} using Three.js.\n */\n export class CustomRuntimeObject3DRenderer\n implements gdjs.RuntimeInstanceContainerRenderer\n {\n _object: gdjs.CustomRuntimeObject3D;\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _isContainerDirty: boolean = true;\n _threeGroup: THREE.Group;\n\n constructor(\n object: gdjs.CustomRuntimeObject3D,\n instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._instanceContainer = instanceContainer;\n\n this._threeGroup = new THREE.Group();\n this._threeGroup.rotation.order = 'ZYX';\n\n const layer = parent.getLayer('');\n if (layer) {\n layer.getRenderer().add3DRendererObject(this._threeGroup);\n }\n }\n\n get3DRendererObject(): THREE.Object3D {\n return this._threeGroup;\n }\n\n getRendererObject() {\n return null;\n }\n\n reinitialize(\n object: gdjs.CustomRuntimeObject3D,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._isContainerDirty = true;\n const layer = parent.getLayer('');\n if (layer) {\n layer.getRenderer().add3DRendererObject(this._threeGroup);\n }\n }\n\n _updateThreeGroup() {\n const threeObject3D = this.get3DRendererObject();\n\n const scaleX = this._object.getScaleX();\n const scaleY = this._object.getScaleY();\n const scaleZ = this._object.getScaleZ();\n const pivotX = this._object.getUnscaledCenterX() * scaleX;\n const pivotY = this._object.getUnscaledCenterY() * scaleY;\n const pivotZ = this._object.getUnscaledCenterZ() * scaleZ;\n\n threeObject3D.rotation.set(\n gdjs.toRad(this._object.getRotationX()),\n gdjs.toRad(this._object.getRotationY()),\n gdjs.toRad(this._object.angle)\n );\n\n threeObject3D.position.set(\n this._object.isFlippedX() ? pivotX : -pivotX,\n this._object.isFlippedY() ? pivotY : -pivotY,\n this._object.isFlippedZ() ? pivotZ : -pivotZ\n );\n threeObject3D.position.applyEuler(threeObject3D.rotation);\n threeObject3D.position.x += this._object.getX() + pivotX;\n threeObject3D.position.y += this._object.getY() + pivotY;\n threeObject3D.position.z += this._object.getZ() + pivotZ;\n\n threeObject3D.scale.set(\n this._object.isFlippedX() ? -scaleX : scaleX,\n this._object.isFlippedY() ? -scaleY : scaleY,\n this._object.isFlippedZ() ? -scaleZ : scaleZ\n );\n\n threeObject3D.visible = !this._object.hidden;\n\n this._isContainerDirty = false;\n }\n\n /**\n * Call this to make sure the object is ready to be rendered.\n */\n ensureUpToDate() {\n if (this._isContainerDirty) {\n this._updateThreeGroup();\n }\n }\n\n update(): void {\n this._isContainerDirty = true;\n }\n\n updateX(): void {\n this._isContainerDirty = true;\n }\n\n updateY(): void {\n this._isContainerDirty = true;\n }\n\n updateAngle(): void {\n this._isContainerDirty = true;\n }\n\n updatePosition() {\n this._isContainerDirty = true;\n }\n\n updateRotation() {\n this._isContainerDirty = true;\n }\n\n updateSize() {\n this._isContainerDirty = true;\n }\n\n updateVisibility(): void {\n this._threeGroup.visible = !this._object.hidden;\n }\n\n updateOpacity(): void {\n // Opacity is not handled by 3D custom objects.\n }\n\n setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {\n // Layers are not handled for 3D custom objects.\n }\n\n static getAnimationFrameTextureManager(\n imageManager: gdjs.PixiImageManager\n ): ThreeAnimationFrameTextureManager {\n if (!imageManager._threeAnimationFrameTextureManager) {\n imageManager._threeAnimationFrameTextureManager =\n new ThreeAnimationFrameTextureManager(imageManager);\n }\n return imageManager._threeAnimationFrameTextureManager;\n }\n }\n\n class ThreeAnimationFrameTextureManager\n implements gdjs.AnimationFrameTextureManager<THREE.Material>\n {\n private _imageManager: gdjs.PixiImageManager;\n\n constructor(imageManager: gdjs.PixiImageManager) {\n this._imageManager = imageManager;\n }\n\n getAnimationFrameTexture(imageName: string) {\n return this._imageManager.getThreeMaterial(imageName, {\n useTransparentTexture: true,\n forceBasicMaterial: true,\n vertexColors: false,\n });\n }\n\n getAnimationFrameWidth(material: THREE.Material) {\n const map = (\n material as THREE.MeshBasicMaterial | THREE.MeshStandardMaterial\n ).map;\n return map ? map.image.width : 0;\n }\n\n getAnimationFrameHeight(material: THREE.Material) {\n const map = (\n material as THREE.MeshBasicMaterial | THREE.MeshStandardMaterial\n ).map;\n return map ? map.image.height : 0;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAOS,OAEP,CAME,YACE,EACA,EACA,EACA,CAPF,uBAA6B,GAQ3B,KAAK,QAAU,EACf,KAAK,mBAAqB,EAE1B,KAAK,YAAc,GAAI,OAAM,MAC7B,KAAK,YAAY,SAAS,MAAQ,MAElC,KAAM,GAAQ,EAAO,SAAS,IAC9B,AAAI,GACF,EAAM,cAAc,oBAAoB,KAAK,aAIjD,qBAAsC,CACpC,MAAO,MAAK,YAGd,mBAAoB,CAClB,MAAO,MAGT,aACE,EACA,EACA,CACA,KAAK,QAAU,E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,CAAC,KAAK,QAAQ,OAG3C,eAAsB,EAItB,cAAc,EAA0B,EAAoB,QAIrD,iCACL,EACmC,CACnC,MAAK,GAAa,oCAChB,GAAa,mCACX,GAAI,GAAkC,IAEnC,EAAa,oCA1IjB,EAAM,gCA8Ib,OAEA,CAGE,YAAY,EAAqC,CAC/C,KAAK,cAAgB,EAGvB,yBAAyB,EAAmB,CAC1C,MAAO,MAAK,cAAc,iBAAiB,EAAW,CACpD,sBAAuB,GACvB,mBAAoB,GACpB,aAAc,KAIlB,uBAAuB,EAA0B,CAC/C,KAAM,GACJ,EACA,IACF,MAAO,GAAM,EAAI,MAAM,MAAQ,EAGjC,wBAAwB,EAA0B,CAChD,KAAM,GACJ,EACA,IACF,MAAO,GAAM,EAAI,MAAM,OAAS,MAjL5B",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(n){const o=r=>{switch(r){case"ModelOrigin":return null;case"ObjectCenter":return[.5,.5,.5];case"BottomCenterZ":return[.5,.5,0];case"BottomCenterY":return[.5,1,.5];case"TopLeft":return[0,0,0];default:return null}};class a extends n.RuntimeObject3D{constructor(e,t){super(e,t);this._materialType=n.Model3DRuntimeObject.MaterialType.Basic;this._currentAnimationIndex=0;this._animationSpeedScale=1;this._animationPaused=!1;this._crossfadeDuration=0;this._modelResourceName=t.content.modelResourceName,this._animations=t.content.animations,this._originPoint=o(t.content.originLocation),this._centerPoint=o(t.content.centerLocation),this._renderer=new n.Model3DRuntimeObjectRenderer(this,e),this._materialType=this._convertMaterialType(t.content.materialType),this.onModelChanged(t),this._crossfadeDuration=t.content.crossfadeDuration||0,this.onCreated()}onModelChanged(e){this._updateModel(e),this._animations.length>0&&this._renderer.playAnimation(this._animations[0].source,this._animations[0].loop)}updateFromObjectData(e,t){return super.updateFromObjectData(e,t),e.content.materialType!==t.content.materialType&&(this._materialType=this._convertMaterialType(t.content.materialType)),e.content.modelResourceName!==t.content.modelResourceName?this._reloadModel(t):(e.content.width!==t.content.width||e.content.height!==t.content.height||e.content.depth!==t.content.depth||e.content.rotationX!==t.content.rotationX||e.content.rotationY!==t.content.rotationY||e.content.rotationZ!==t.content.rotationZ||e.content.keepAspectRatio!==t.content.keepAspectRatio||e.content.materialType!==t.content.materialType)&&this._updateModel(t),e.content.originLocation!==t.content.originLocation&&(this._originPoint=o(t.content.originLocation)),e.content.centerLocation!==t.content.centerLocation&&(this._centerPoint=o(t.content.centerLocation)),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),mt:this._materialType,op:this._originPoint,cp:this._centerPoint,anis:this._animations,ai:this._currentAnimationIndex,ass:this._animationSpeedScale,ap:this._animationPaused,cfd:this._crossfadeDuration}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.mt!==void 0&&(this._materialType=e.mt),e.op!==void 0&&(this._originPoint=e.op),e.cp!==void 0&&(this._centerPoint=e.cp),e.anis!==void 0&&(this._animations=e.anis),e.ai!==void 0&&this.setAnimationIndex(e.ai),e.ass!==void 0&&this.setAnimationSpeedScale(e.ass),e.ap!==void 0&&e.ap!==this.isAnimationPaused()&&(e.ap?this.pauseAnimation():this.resumeAnimation()),e.cfd!==void 0&&(this._crossfadeDuration=e.cfd)}_reloadModel(e){this._modelResourceName=e.content.modelResourceName,this._renderer._reloadModel(this,this._runtimeScene),this.onModelChanged(e)}_updateModel(e){const t=e.content.rotationX||0,s=e.content.rotationY||0,d=e.content.rotationZ||0,i=e.content.keepAspectRatio;this._renderer._updateModel(t,s,d,this._getOriginalWidth(),this._getOriginalHeight(),this._getOriginalDepth(),i)}getRenderer(){return this._renderer}_convertMaterialType(e){return e==="KeepOriginal"?n.Model3DRuntimeObject.MaterialType.KeepOriginal:e==="StandardWithoutMetalness"?n.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness:n.Model3DRuntimeObject.MaterialType.Basic}update(e){const t=this.getElapsedTime()/1e3;this._renderer.updateAnimation(t
|
|
1
|
+
var gdjs;(function(n){const o=r=>{switch(r){case"ModelOrigin":return null;case"ObjectCenter":return[.5,.5,.5];case"BottomCenterZ":return[.5,.5,0];case"BottomCenterY":return[.5,1,.5];case"TopLeft":return[0,0,0];default:return null}};class a extends n.RuntimeObject3D{constructor(e,t){super(e,t);this._materialType=n.Model3DRuntimeObject.MaterialType.Basic;this._currentAnimationIndex=0;this._animationSpeedScale=1;this._animationPaused=!1;this._crossfadeDuration=0;this._modelResourceName=t.content.modelResourceName,this._animations=t.content.animations,this._originPoint=o(t.content.originLocation),this._centerPoint=o(t.content.centerLocation),this._renderer=new n.Model3DRuntimeObjectRenderer(this,e),this._materialType=this._convertMaterialType(t.content.materialType),this.onModelChanged(t),this._crossfadeDuration=t.content.crossfadeDuration||0,this.onCreated()}onModelChanged(e){this._updateModel(e),this._animations.length>0&&this._renderer.playAnimation(this._animations[0].source,this._animations[0].loop)}updateFromObjectData(e,t){return super.updateFromObjectData(e,t),e.content.materialType!==t.content.materialType&&(this._materialType=this._convertMaterialType(t.content.materialType)),e.content.modelResourceName!==t.content.modelResourceName?this._reloadModel(t):(e.content.width!==t.content.width||e.content.height!==t.content.height||e.content.depth!==t.content.depth||e.content.rotationX!==t.content.rotationX||e.content.rotationY!==t.content.rotationY||e.content.rotationZ!==t.content.rotationZ||e.content.keepAspectRatio!==t.content.keepAspectRatio||e.content.materialType!==t.content.materialType)&&this._updateModel(t),e.content.originLocation!==t.content.originLocation&&(this._originPoint=o(t.content.originLocation)),e.content.centerLocation!==t.content.centerLocation&&(this._centerPoint=o(t.content.centerLocation)),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),mt:this._materialType,op:this._originPoint,cp:this._centerPoint,anis:this._animations,ai:this._currentAnimationIndex,ass:this._animationSpeedScale,ap:this._animationPaused,cfd:this._crossfadeDuration}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.mt!==void 0&&(this._materialType=e.mt),e.op!==void 0&&(this._originPoint=e.op),e.cp!==void 0&&(this._centerPoint=e.cp),e.anis!==void 0&&(this._animations=e.anis),e.ai!==void 0&&this.setAnimationIndex(e.ai),e.ass!==void 0&&this.setAnimationSpeedScale(e.ass),e.ap!==void 0&&e.ap!==this.isAnimationPaused()&&(e.ap?this.pauseAnimation():this.resumeAnimation()),e.cfd!==void 0&&(this._crossfadeDuration=e.cfd)}_reloadModel(e){this._modelResourceName=e.content.modelResourceName,this._renderer._reloadModel(this,this._runtimeScene),this.onModelChanged(e)}_updateModel(e){const t=e.content.rotationX||0,s=e.content.rotationY||0,d=e.content.rotationZ||0,i=e.content.keepAspectRatio;this._renderer._updateModel(t,s,d,this._getOriginalWidth(),this._getOriginalHeight(),this._getOriginalDepth(),i)}getRenderer(){return this._renderer}_convertMaterialType(e){return e==="KeepOriginal"?n.Model3DRuntimeObject.MaterialType.KeepOriginal:e==="StandardWithoutMetalness"?n.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness:n.Model3DRuntimeObject.MaterialType.Basic}update(e){const t=this.getElapsedTime()/1e3;this._renderer.updateAnimation(t)}getAnimationIndex(){return this._currentAnimationIndex}setAnimationIndex(e){if(e=e|0,e<this._animations.length&&this._currentAnimationIndex!==e&&e>=0){const t=this._animations[e];this._currentAnimationIndex=e,this._renderer.playAnimation(t.source,t.loop),this._animationPaused&&this._renderer.pauseAnimation()}}getAnimationName(){return this._currentAnimationIndex>=this._animations.length?"":this._animations[this._currentAnimationIndex].name}setAnimationName(e){if(!e)return;const t=this._animations.findIndex(s=>s.name===e);t>=0&&this.setAnimationIndex(t)}isCurrentAnimationName(e){return this.getAnimationName()===e}hasAnimationEnded(){return this._renderer.hasAnimationEnded()}setCrossfadeDuration(e){this._crossfadeDuration!==e&&(this._crossfadeDuration=e)}isAnimationPaused(){return this._animationPaused}pauseAnimation(){this._animationPaused=!0,this._renderer.pauseAnimation()}resumeAnimation(){this._animationPaused=!1,this._renderer.resumeAnimation()}getAnimationSpeedScale(){return this._animationSpeedScale}setAnimationSpeedScale(e){this._animationSpeedScale=e,this._renderer.setAnimationTimeScale(e)}getAnimationElapsedTime(){return this._renderer.getAnimationElapsedTime()}setAnimationElapsedTime(e){this._renderer.setAnimationElapsedTime(e),this._animationPaused||this._renderer.resumeAnimation()}getAnimationDuration(){return this._renderer.getAnimationDuration(this._animations[this._currentAnimationIndex].source)}getCenterX(){const e=this._renderer.getCenterPoint();return this.getWidth()*e[0]}getCenterY(){const e=this._renderer.getCenterPoint();return this.getHeight()*e[1]}getCenterZ(){const e=this._renderer.getCenterPoint();return this.getDepth()*e[2]}getDrawableX(){const e=this._renderer.getOriginPoint();return this.getX()-this.getWidth()*e[0]}getDrawableY(){const e=this._renderer.getOriginPoint();return this.getY()-this.getHeight()*e[1]}getDrawableZ(){const e=this._renderer.getOriginPoint();return this.getZ()-this.getDepth()*e[2]}}n.Model3DRuntimeObject=a,function(e){let r;(function(i){i[i.Basic=0]="Basic",i[i.StandardWithoutMetalness=1]="StandardWithoutMetalness",i[i.KeepOriginal=2]="KeepOriginal"})(r=e.MaterialType||(e.MaterialType={}))}(a=n.Model3DRuntimeObject||(n.Model3DRuntimeObject={})),n.registerObject("Scene3D::Model3DObject",n.Model3DRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=Model3DRuntimeObject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/Model3DRuntimeObject.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n type Model3DAnimation = { name: string; source: string; loop: boolean };\n\n type Model3DObjectNetworkSyncDataType = {\n mt: number;\n op: FloatPoint3D | null;\n cp: FloatPoint3D | null;\n anis: Model3DAnimation[];\n ai: integer;\n ass: float;\n ap: boolean;\n cfd: float;\n };\n\n type Model3DObjectNetworkSyncData = Object3DNetworkSyncData &\n Model3DObjectNetworkSyncDataType;\n\n /** Base parameters for {@link gdjs.Cube3DRuntimeObject} */\n export interface Model3DObjectData extends Object3DData {\n /** The base parameters of the Model3D object */\n content: Object3DDataContent & {\n modelResourceName: string;\n rotationX: number;\n rotationY: number;\n rotationZ: number;\n keepAspectRatio: boolean;\n materialType: 'Basic' | 'StandardWithoutMetalness' | 'KeepOriginal';\n originLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY'\n | 'TopLeft';\n centerLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY';\n animations: Model3DAnimation[];\n crossfadeDuration: float;\n };\n }\n\n type FloatPoint3D = [float, float, float];\n\n const getPointForLocation = (location: string): FloatPoint3D | null => {\n switch (location) {\n case 'ModelOrigin':\n return null;\n case 'ObjectCenter':\n return [0.5, 0.5, 0.5];\n case 'BottomCenterZ':\n return [0.5, 0.5, 0];\n case 'BottomCenterY':\n return [0.5, 1, 0.5];\n case 'TopLeft':\n return [0, 0, 0];\n default:\n return null;\n }\n };\n\n /**\n * A 3D object which displays a 3D model.\n */\n export class Model3DRuntimeObject\n extends gdjs.RuntimeObject3D\n implements gdjs.Animatable\n {\n _renderer: gdjs.Model3DRuntimeObjectRenderer;\n\n _modelResourceName: string;\n _materialType: gdjs.Model3DRuntimeObject.MaterialType =\n gdjs.Model3DRuntimeObject.MaterialType.Basic;\n\n /**\n * The local point of the model that will be at the object position.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getOriginPoint\n */\n _originPoint: FloatPoint3D | null;\n /**\n * The local point of the model that is used as rotation center.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getCenterPoint\n */\n _centerPoint: FloatPoint3D | null;\n\n _animations: Model3DAnimation[];\n _currentAnimationIndex: integer = 0;\n _animationSpeedScale: float = 1;\n _animationPaused: boolean = false;\n _crossfadeDuration: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: Model3DObjectData\n ) {\n super(instanceContainer, objectData);\n this._modelResourceName = objectData.content.modelResourceName;\n this._animations = objectData.content.animations;\n this._originPoint = getPointForLocation(\n objectData.content.originLocation\n );\n this._centerPoint = getPointForLocation(\n objectData.content.centerLocation\n );\n this._renderer = new gdjs.Model3DRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._materialType = this._convertMaterialType(\n objectData.content.materialType\n );\n\n this.onModelChanged(objectData);\n\n this._crossfadeDuration = objectData.content.crossfadeDuration || 0;\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n /**\n * To be called after the renderer loaded a Model resource:\n * - After the renderer was instantiated\n * - After reloading the model\n */\n private onModelChanged(objectData) {\n this._updateModel(objectData);\n if (this._animations.length > 0) {\n this._renderer.playAnimation(\n this._animations[0].source,\n this._animations[0].loop\n );\n }\n }\n\n updateFromObjectData(\n oldObjectData: Model3DObjectData,\n newObjectData: Model3DObjectData\n ): boolean {\n super.updateFromObjectData(oldObjectData, newObjectData);\n\n if (\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this._materialType = this._convertMaterialType(\n newObjectData.content.materialType\n );\n }\n if (\n oldObjectData.content.modelResourceName !==\n newObjectData.content.modelResourceName\n ) {\n this._reloadModel(newObjectData);\n } else if (\n oldObjectData.content.width !== newObjectData.content.width ||\n oldObjectData.content.height !== newObjectData.content.height ||\n oldObjectData.content.depth !== newObjectData.content.depth ||\n oldObjectData.content.rotationX !== newObjectData.content.rotationX ||\n oldObjectData.content.rotationY !== newObjectData.content.rotationY ||\n oldObjectData.content.rotationZ !== newObjectData.content.rotationZ ||\n oldObjectData.content.keepAspectRatio !==\n newObjectData.content.keepAspectRatio ||\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this._updateModel(newObjectData);\n }\n if (\n oldObjectData.content.originLocation !==\n newObjectData.content.originLocation\n ) {\n this._originPoint = getPointForLocation(\n newObjectData.content.originLocation\n );\n }\n if (\n oldObjectData.content.centerLocation !==\n newObjectData.content.centerLocation\n ) {\n this._centerPoint = getPointForLocation(\n newObjectData.content.centerLocation\n );\n }\n return true;\n }\n\n getNetworkSyncData(): Model3DObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n mt: this._materialType,\n op: this._originPoint,\n cp: this._centerPoint,\n anis: this._animations,\n ai: this._currentAnimationIndex,\n ass: this._animationSpeedScale,\n ap: this._animationPaused,\n cfd: this._crossfadeDuration,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: Model3DObjectNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.mt !== undefined) {\n this._materialType = networkSyncData.mt;\n }\n if (networkSyncData.op !== undefined) {\n this._originPoint = networkSyncData.op;\n }\n if (networkSyncData.cp !== undefined) {\n this._centerPoint = networkSyncData.cp;\n }\n if (networkSyncData.anis !== undefined) {\n this._animations = networkSyncData.anis;\n }\n if (networkSyncData.ai !== undefined) {\n this.setAnimationIndex(networkSyncData.ai);\n }\n if (networkSyncData.ass !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.ass);\n }\n if (networkSyncData.ap !== undefined) {\n if (networkSyncData.ap !== this.isAnimationPaused()) {\n networkSyncData.ap ? this.pauseAnimation() : this.resumeAnimation();\n }\n }\n if (networkSyncData.cfd !== undefined) {\n this._crossfadeDuration = networkSyncData.cfd;\n }\n }\n\n _reloadModel(objectData: Model3DObjectData) {\n this._modelResourceName = objectData.content.modelResourceName;\n this._renderer._reloadModel(this, this._runtimeScene);\n this.onModelChanged(objectData);\n }\n\n _updateModel(objectData: Model3DObjectData) {\n const rotationX = objectData.content.rotationX || 0;\n const rotationY = objectData.content.rotationY || 0;\n const rotationZ = objectData.content.rotationZ || 0;\n const keepAspectRatio = objectData.content.keepAspectRatio;\n this._renderer._updateModel(\n rotationX,\n rotationY,\n rotationZ,\n this._getOriginalWidth(),\n this._getOriginalHeight(),\n this._getOriginalDepth(),\n keepAspectRatio\n );\n }\n\n getRenderer(): RuntimeObject3DRenderer {\n return this._renderer;\n }\n\n _convertMaterialType(\n materialTypeString: string\n ): gdjs.Model3DRuntimeObject.MaterialType {\n if (materialTypeString === 'KeepOriginal') {\n return gdjs.Model3DRuntimeObject.MaterialType.KeepOriginal;\n } else if (materialTypeString === 'StandardWithoutMetalness') {\n return gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n } else {\n return gdjs.Model3DRuntimeObject.MaterialType.Basic;\n }\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n const elapsedTime = this.getElapsedTime() / 1000;\n this._renderer.updateAnimation(elapsedTime * this._animationSpeedScale);\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n */\n getAnimationIndex(): number {\n return this._currentAnimationIndex;\n }\n\n /**\n * Change the animation being played.\n * @param animationIndex The index of the new animation to be played\n */\n setAnimationIndex(animationIndex: number): void {\n animationIndex = animationIndex | 0;\n if (\n animationIndex < this._animations.length &&\n this._currentAnimationIndex !== animationIndex &&\n animationIndex >= 0\n ) {\n const animation = this._animations[animationIndex];\n this._currentAnimationIndex = animationIndex;\n this._renderer.playAnimation(animation.source, animation.loop);\n if (this._animationPaused) {\n this._renderer.pauseAnimation();\n }\n }\n }\n\n /**\n * Get the name of the animation being played.\n * @return The name of the new animation being played\n */\n getAnimationName(): string {\n if (this._currentAnimationIndex >= this._animations.length) {\n return '';\n }\n return this._animations[this._currentAnimationIndex].name;\n }\n\n /**\n * Change the animation being played.\n * @param newAnimationName The name of the new animation to be played\n */\n setAnimationName(newAnimationName: string): void {\n if (!newAnimationName) {\n return;\n }\n const animationIndex = this._animations.findIndex(\n (animation) => animation.name === newAnimationName\n );\n if (animationIndex >= 0) {\n this.setAnimationIndex(animationIndex);\n }\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n return this._renderer.hasAnimationEnded();\n }\n\n setCrossfadeDuration(duration: number): void {\n if (this._crossfadeDuration === duration) return;\n this._crossfadeDuration = duration;\n }\n\n isAnimationPaused() {\n return this._animationPaused;\n }\n\n pauseAnimation() {\n this._animationPaused = true;\n this._renderer.pauseAnimation();\n }\n\n resumeAnimation() {\n this._animationPaused = false;\n this._renderer.resumeAnimation();\n }\n\n getAnimationSpeedScale() {\n return this._animationSpeedScale;\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animationSpeedScale = ratio;\n }\n\n getAnimationElapsedTime(): float {\n return this._renderer.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n this._renderer.setAnimationElapsedTime(time);\n if (!this._animationPaused) {\n this._renderer.resumeAnimation();\n }\n }\n\n getAnimationDuration(): float {\n return this._renderer.getAnimationDuration(\n this._animations[this._currentAnimationIndex].source\n );\n }\n\n getCenterX(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getWidth() * centerPoint[0];\n }\n\n getCenterY(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getHeight() * centerPoint[1];\n }\n\n getCenterZ(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getDepth() * centerPoint[2];\n }\n\n getDrawableX(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getX() - this.getWidth() * originPoint[0];\n }\n\n getDrawableY(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getY() - this.getHeight() * originPoint[1];\n }\n\n getDrawableZ(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getZ() - this.getDepth() * originPoint[2];\n }\n }\n\n export namespace Model3DRuntimeObject {\n export enum MaterialType {\n Basic,\n StandardWithoutMetalness,\n KeepOriginal,\n }\n }\n gdjs.registerObject('Sc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WAAa,EAC5C,EAAkB,EAAW,QAAQ,gBAC3C,KAAK,UAAU,aACb,EACA,EACA,EACA,KAAK,oBACL,KAAK,qBACL,KAAK,oBACL,GAIJ,aAAuC,CACrC,MAAO,MAAK,UAGd,qBACE,EACwC,CACxC,MAAI,KAAuB,eAClB,EAAK,qBAAqB,aAAa,aACrC,IAAuB,2BACzB,EAAK,qBAAqB,aAAa,yBAEvC,EAAK,qBAAqB,aAAa,MAIlD,OAAO,EAAwD,CAC7D,KAAM,GAAc,KAAK,iBAAmB,IAC5C,KAAK,UAAU,gBAAgB,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n type Model3DAnimation = { name: string; source: string; loop: boolean };\n\n type Model3DObjectNetworkSyncDataType = {\n mt: number;\n op: FloatPoint3D | null;\n cp: FloatPoint3D | null;\n anis: Model3DAnimation[];\n ai: integer;\n ass: float;\n ap: boolean;\n cfd: float;\n };\n\n type Model3DObjectNetworkSyncData = Object3DNetworkSyncData &\n Model3DObjectNetworkSyncDataType;\n\n /** Base parameters for {@link gdjs.Cube3DRuntimeObject} */\n export interface Model3DObjectData extends Object3DData {\n /** The base parameters of the Model3D object */\n content: Object3DDataContent & {\n modelResourceName: string;\n rotationX: number;\n rotationY: number;\n rotationZ: number;\n keepAspectRatio: boolean;\n materialType: 'Basic' | 'StandardWithoutMetalness' | 'KeepOriginal';\n originLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY'\n | 'TopLeft';\n centerLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY';\n animations: Model3DAnimation[];\n crossfadeDuration: float;\n };\n }\n\n type FloatPoint3D = [float, float, float];\n\n const getPointForLocation = (location: string): FloatPoint3D | null => {\n switch (location) {\n case 'ModelOrigin':\n return null;\n case 'ObjectCenter':\n return [0.5, 0.5, 0.5];\n case 'BottomCenterZ':\n return [0.5, 0.5, 0];\n case 'BottomCenterY':\n return [0.5, 1, 0.5];\n case 'TopLeft':\n return [0, 0, 0];\n default:\n return null;\n }\n };\n\n /**\n * A 3D object which displays a 3D model.\n */\n export class Model3DRuntimeObject\n extends gdjs.RuntimeObject3D\n implements gdjs.Animatable\n {\n _renderer: gdjs.Model3DRuntimeObjectRenderer;\n\n _modelResourceName: string;\n _materialType: gdjs.Model3DRuntimeObject.MaterialType =\n gdjs.Model3DRuntimeObject.MaterialType.Basic;\n\n /**\n * The local point of the model that will be at the object position.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getOriginPoint\n */\n _originPoint: FloatPoint3D | null;\n /**\n * The local point of the model that is used as rotation center.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getCenterPoint\n */\n _centerPoint: FloatPoint3D | null;\n\n _animations: Model3DAnimation[];\n _currentAnimationIndex: integer = 0;\n _animationSpeedScale: float = 1;\n _animationPaused: boolean = false;\n _crossfadeDuration: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: Model3DObjectData\n ) {\n super(instanceContainer, objectData);\n this._modelResourceName = objectData.content.modelResourceName;\n this._animations = objectData.content.animations;\n this._originPoint = getPointForLocation(\n objectData.content.originLocation\n );\n this._centerPoint = getPointForLocation(\n objectData.content.centerLocation\n );\n this._renderer = new gdjs.Model3DRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._materialType = this._convertMaterialType(\n objectData.content.materialType\n );\n\n this.onModelChanged(objectData);\n\n this._crossfadeDuration = objectData.content.crossfadeDuration || 0;\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n /**\n * To be called after the renderer loaded a Model resource:\n * - After the renderer was instantiated\n * - After reloading the model\n */\n private onModelChanged(objectData) {\n this._updateModel(objectData);\n if (this._animations.length > 0) {\n this._renderer.playAnimation(\n this._animations[0].source,\n this._animations[0].loop\n );\n }\n }\n\n updateFromObjectData(\n oldObjectData: Model3DObjectData,\n newObjectData: Model3DObjectData\n ): boolean {\n super.updateFromObjectData(oldObjectData, newObjectData);\n\n if (\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this._materialType = this._convertMaterialType(\n newObjectData.content.materialType\n );\n }\n if (\n oldObjectData.content.modelResourceName !==\n newObjectData.content.modelResourceName\n ) {\n this._reloadModel(newObjectData);\n } else if (\n oldObjectData.content.width !== newObjectData.content.width ||\n oldObjectData.content.height !== newObjectData.content.height ||\n oldObjectData.content.depth !== newObjectData.content.depth ||\n oldObjectData.content.rotationX !== newObjectData.content.rotationX ||\n oldObjectData.content.rotationY !== newObjectData.content.rotationY ||\n oldObjectData.content.rotationZ !== newObjectData.content.rotationZ ||\n oldObjectData.content.keepAspectRatio !==\n newObjectData.content.keepAspectRatio ||\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this._updateModel(newObjectData);\n }\n if (\n oldObjectData.content.originLocation !==\n newObjectData.content.originLocation\n ) {\n this._originPoint = getPointForLocation(\n newObjectData.content.originLocation\n );\n }\n if (\n oldObjectData.content.centerLocation !==\n newObjectData.content.centerLocation\n ) {\n this._centerPoint = getPointForLocation(\n newObjectData.content.centerLocation\n );\n }\n return true;\n }\n\n getNetworkSyncData(): Model3DObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n mt: this._materialType,\n op: this._originPoint,\n cp: this._centerPoint,\n anis: this._animations,\n ai: this._currentAnimationIndex,\n ass: this._animationSpeedScale,\n ap: this._animationPaused,\n cfd: this._crossfadeDuration,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: Model3DObjectNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.mt !== undefined) {\n this._materialType = networkSyncData.mt;\n }\n if (networkSyncData.op !== undefined) {\n this._originPoint = networkSyncData.op;\n }\n if (networkSyncData.cp !== undefined) {\n this._centerPoint = networkSyncData.cp;\n }\n if (networkSyncData.anis !== undefined) {\n this._animations = networkSyncData.anis;\n }\n if (networkSyncData.ai !== undefined) {\n this.setAnimationIndex(networkSyncData.ai);\n }\n if (networkSyncData.ass !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.ass);\n }\n if (networkSyncData.ap !== undefined) {\n if (networkSyncData.ap !== this.isAnimationPaused()) {\n networkSyncData.ap ? this.pauseAnimation() : this.resumeAnimation();\n }\n }\n if (networkSyncData.cfd !== undefined) {\n this._crossfadeDuration = networkSyncData.cfd;\n }\n }\n\n _reloadModel(objectData: Model3DObjectData) {\n this._modelResourceName = objectData.content.modelResourceName;\n this._renderer._reloadModel(this, this._runtimeScene);\n this.onModelChanged(objectData);\n }\n\n _updateModel(objectData: Model3DObjectData) {\n const rotationX = objectData.content.rotationX || 0;\n const rotationY = objectData.content.rotationY || 0;\n const rotationZ = objectData.content.rotationZ || 0;\n const keepAspectRatio = objectData.content.keepAspectRatio;\n this._renderer._updateModel(\n rotationX,\n rotationY,\n rotationZ,\n this._getOriginalWidth(),\n this._getOriginalHeight(),\n this._getOriginalDepth(),\n keepAspectRatio\n );\n }\n\n getRenderer(): RuntimeObject3DRenderer {\n return this._renderer;\n }\n\n _convertMaterialType(\n materialTypeString: string\n ): gdjs.Model3DRuntimeObject.MaterialType {\n if (materialTypeString === 'KeepOriginal') {\n return gdjs.Model3DRuntimeObject.MaterialType.KeepOriginal;\n } else if (materialTypeString === 'StandardWithoutMetalness') {\n return gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n } else {\n return gdjs.Model3DRuntimeObject.MaterialType.Basic;\n }\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n const elapsedTime = this.getElapsedTime() / 1000;\n this._renderer.updateAnimation(elapsedTime);\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n */\n getAnimationIndex(): number {\n return this._currentAnimationIndex;\n }\n\n /**\n * Change the animation being played.\n * @param animationIndex The index of the new animation to be played\n */\n setAnimationIndex(animationIndex: number): void {\n animationIndex = animationIndex | 0;\n if (\n animationIndex < this._animations.length &&\n this._currentAnimationIndex !== animationIndex &&\n animationIndex >= 0\n ) {\n const animation = this._animations[animationIndex];\n this._currentAnimationIndex = animationIndex;\n this._renderer.playAnimation(animation.source, animation.loop);\n if (this._animationPaused) {\n this._renderer.pauseAnimation();\n }\n }\n }\n\n /**\n * Get the name of the animation being played.\n * @return The name of the new animation being played\n */\n getAnimationName(): string {\n if (this._currentAnimationIndex >= this._animations.length) {\n return '';\n }\n return this._animations[this._currentAnimationIndex].name;\n }\n\n /**\n * Change the animation being played.\n * @param newAnimationName The name of the new animation to be played\n */\n setAnimationName(newAnimationName: string): void {\n if (!newAnimationName) {\n return;\n }\n const animationIndex = this._animations.findIndex(\n (animation) => animation.name === newAnimationName\n );\n if (animationIndex >= 0) {\n this.setAnimationIndex(animationIndex);\n }\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n return this._renderer.hasAnimationEnded();\n }\n\n setCrossfadeDuration(duration: number): void {\n if (this._crossfadeDuration === duration) return;\n this._crossfadeDuration = duration;\n }\n\n isAnimationPaused() {\n return this._animationPaused;\n }\n\n pauseAnimation() {\n this._animationPaused = true;\n this._renderer.pauseAnimation();\n }\n\n resumeAnimation() {\n this._animationPaused = false;\n this._renderer.resumeAnimation();\n }\n\n getAnimationSpeedScale() {\n return this._animationSpeedScale;\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animationSpeedScale = ratio;\n this._renderer.setAnimationTimeScale(ratio);\n }\n\n getAnimationElapsedTime(): float {\n return this._renderer.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n this._renderer.setAnimationElapsedTime(time);\n if (!this._animationPaused) {\n this._renderer.resumeAnimation();\n }\n }\n\n getAnimationDuration(): float {\n return this._renderer.getAnimationDuration(\n this._animations[this._currentAnimationIndex].source\n );\n }\n\n getCenterX(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getWidth() * centerPoint[0];\n }\n\n getCenterY(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getHeight() * centerPoint[1];\n }\n\n getCenterZ(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getDepth() * centerPoint[2];\n }\n\n getDrawableX(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getX() - this.getWidth() * originPoint[0];\n }\n\n getDrawableY(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getY() - this.getHeight() * originPoint[1];\n }\n\n getDrawableZ(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getZ() - this.getDepth() * originPoint[2];\n }\n }\n\n export namespace Model3DRuntimeObject {\n export enum MaterialType {\n Basic,\n StandardWithoutMetalness,\n KeepOriginal,\n }\n }\n gdjs.registerObject('Scene3D::Model3DObject', gdjs.Model3DRuntimeObject);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CA6CE,KAAM,GAAsB,AAAC,GAA0C,CACrE,OAAQ,OACD,cACH,MAAO,UACJ,eACH,MAAO,CAAC,GAAK,GAAK,QACf,gBACH,MAAO,CAAC,GAAK,GAAK,OACf,gBACH,MAAO,CAAC,GAAK,EAAG,QACb,UACH,MAAO,CAAC,EAAG,EAAG,WAEd,MAAO,QAON,eACG,GAAK,eAEf,CAoCE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GApC3B,mBACE,EAAK,qBAAqB,aAAa,MA0BzC,4BAAkC,EAClC,0BAA8B,EAC9B,sBAA4B,GAC5B,wBAA4B,EAO1B,KAAK,mBAAqB,EAAW,QAAQ,kBAC7C,KAAK,YAAc,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AU,iBACnC,MAAO,MAAK,OAAS,KAAK,WAAa,EAAY,GAGrD,cAAsB,CACpB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,OAAS,KAAK,YAAc,EAAY,GAGtD,cAAsB,CACpB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,OAAS,KAAK,WAAa,EAAY,IA/WhD,EAAM,uBAmXN,SAAU,EAAV,CACE,GAAK,GAAL,UAAK,EAAL,CACL,qBACA,2DACA,qCAHU,wCADG,uDAOjB,EAAK,eAAe,yBAA0B,EAAK,wBA3b3C",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(a){const s=1/(1<<16),g=i=>{i.metalness&&(i.metalness=0)},O=i=>{const t=i;if(!!t.material)if(Array.isArray(t.material))for(let e=0;e<t.material.length;e++)g(t.material[e]);else g(t.material)},T=i=>i.traverse(O),M=i=>{const t=new THREE.MeshBasicMaterial;return i.color&&(t.color=i.color),i.map&&(t.map=i.map),t},
|
|
1
|
+
var gdjs;(function(a){const s=1/(1<<16),g=i=>{i.metalness&&(i.metalness=0)},O=i=>{const t=i;if(!!t.material)if(Array.isArray(t.material))for(let e=0;e<t.material.length;e++)g(t.material[e]);else g(t.material)},T=i=>i.traverse(O),M=i=>{const t=new THREE.MeshBasicMaterial;return i.color&&(t.color=i.color),i.map&&(t.map=i.map),t},D=i=>{const t=i;if(!!t.material)if(Array.isArray(t.material))for(let e=0;e<t.material.length;e++)t.material[e]=M(t.material[e]);else t.material=M(t.material)},b=i=>i.traverse(D);class j extends a.RuntimeObject3DRenderer{constructor(t,e){const r=e.getGame().getModel3DManager().getModel(t._modelResourceName),o=new THREE.Group,h=new THREE.Group;h.rotation.order="ZYX",h.add(o);super(t,e,h);this._model3DRuntimeObject=t,this._threeObject=o,this._originalModel=r,this._modelOriginPoint=[0,0,0],this.updateSize(),this.updatePosition(),this.updateRotation(),this._animationMixer=new THREE.AnimationMixer(o),this._action=null}updateAnimation(t){this._animationMixer.update(t)}updatePosition(){const t=this.getOriginPoint(),e=this.getCenterPoint();this.get3DRendererObject().position.set(this._object.getX()-this._object.getWidth()*(t[0]-e[0]),this._object.getY()-this._object.getHeight()*(t[1]-e[1]),this._object.getZ()-this._object.getDepth()*(t[2]-e[2]))}getOriginPoint(){return this._model3DRuntimeObject._originPoint||this._modelOriginPoint}getCenterPoint(){return this._model3DRuntimeObject._centerPoint||this._modelOriginPoint}_updateDefaultTransformation(t,e,r,o,h,R,p,l){t.rotation.set(a.toRad(e),a.toRad(r),a.toRad(o)),t.updateMatrixWorld(!0);const n=new THREE.Box3().setFromObject(t);!this._model3DRuntimeObject._originPoint&&n.expandByPoint(new THREE.Vector3(0,0,0));const m=n.max.x-n.min.x,c=n.max.y-n.min.y,d=n.max.z-n.min.z;this._modelOriginPoint[0]=m<s?0:-n.min.x/m,this._modelOriginPoint[1]=c<s?0:-n.min.y/c,this._modelOriginPoint[2]=d<s?0:-n.min.z/d,this._modelOriginPoint[1]=1-this._modelOriginPoint[1];const u=this._model3DRuntimeObject._centerPoint;u&&t.position.set(-(n.min.x+m*u[0]),-(n.min.y+c*(1-u[1])),-(n.min.z+d*u[2])),t.scale.set(1,1,1),t.rotation.set(a.toRad(e),a.toRad(r),a.toRad(o));const A=m<s?1:1/m,H=c<s?1:1/c,P=d<s?1:1/d,f=new THREE.Matrix4;if(f.makeScale(A,-H,P),t.updateMatrix(),t.applyMatrix4(f),l){const x=m<s?Number.POSITIVE_INFINITY:h/m,I=c<s?Number.POSITIVE_INFINITY:R/c,v=d<s?Number.POSITIVE_INFINITY:p/d;let _=Math.min(x,I,v);Number.isFinite(_)||(_=1),this._object._setOriginalWidth(_*m),this._object._setOriginalHeight(_*c),this._object._setOriginalDepth(_*d)}}_reloadModel(t,e){this._originalModel=e.getGame().getModel3DManager().getModel(t._modelResourceName)}_updateModel(t,e,r,o,h,R,p){const l=new THREE.Group;l.rotation.order="ZYX";const n=THREE_ADDONS.SkeletonUtils.clone(this._originalModel.scene);l.add(n),this._replaceMaterials(l),this._updateDefaultTransformation(l,t,e,r,o,h,R,p),this.get3DRendererObject().remove(this._threeObject),this.get3DRendererObject().add(l),this._threeObject=l,this._animationMixer=new THREE.AnimationMixer(n);const E=this._model3DRuntimeObject.isAnimationPaused();this._model3DRuntimeObject.setAnimationIndex(this._model3DRuntimeObject.getAnimationIndex()),E&&this.pauseAnimation()}_replaceMaterials(t){this._model3DRuntimeObject._materialType===a.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness?T(t):this._model3DRuntimeObject._materialType===a.Model3DRuntimeObject.MaterialType.Basic&&b(t)}getAnimationCount(){return this._originalModel.animations.length}getAnimationName(t){return this._originalModel.animations[t].name}hasAnimationEnded(){return this._action?!this._action.isRunning():!0}animationPaused(){if(!!this._action)return this._action.paused}pauseAnimation(){!this._action||(this._action.paused=!0)}resumeAnimation(){!this._action||(this._action.paused=!1)}playAnimation(t,e){const r=THREE.AnimationClip.findByName(this._originalModel.animations,t);if(!r){console.error(`The GLB file: ${this._model3DRuntimeObject._modelResourceName} doesn't have any animation named: ${t}`);return}const o=this._action;this._action=this._animationMixer.clipAction(r),this._action.reset(),this._action.setLoop(e?THREE.LoopRepeat:THREE.LoopOnce,Number.POSITIVE_INFINITY),this._action.clampWhenFinished=!0,this._action.timeScale=this._model3DRuntimeObject.getAnimationSpeedScale(),o&&o!==this._action&&this._action.crossFadeFrom(o,this._model3DRuntimeObject._crossfadeDuration,!1),this._action.play(),this._animationMixer.update(0)}getAnimationElapsedTime(){return this._action?this._action.time:0}setAnimationElapsedTime(t){this._action&&(this._action.time=t)}setAnimationTimeScale(t){this._action&&(this._action.timeScale=t)}getAnimationDuration(t){const e=THREE.AnimationClip.findByName(this._originalModel.animations,t);return e?e.duration:0}}a.Model3DRuntimeObjectRenderer=j})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=Model3DRuntimeObject3DRenderer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/Model3DRuntimeObject3DRenderer.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n type FloatPoint3D = [float, float, float];\n\n const epsilon = 1 / (1 << 16);\n\n const removeMetalness = (material: THREE.Material): void => {\n //@ts-ignore\n if (material.metalness) {\n //@ts-ignore\n material.metalness = 0;\n }\n };\n\n const removeMetalnessFromMesh = (node: THREE.Object3D) => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n removeMetalness(mesh.material[index]);\n }\n } else {\n removeMetalness(mesh.material);\n }\n };\n\n const traverseToRemoveMetalnessFromMeshes = (node: THREE.Object3D) =>\n node.traverse(removeMetalnessFromMesh);\n\n const convertToBasicMaterial = (\n material: THREE.Material\n ): THREE.MeshBasicMaterial => {\n const basicMaterial = new THREE.MeshBasicMaterial();\n //@ts-ignore\n if (material.color) {\n //@ts-ignore\n basicMaterial.color = material.color;\n }\n //@ts-ignore\n if (material.map) {\n //@ts-ignore\n basicMaterial.map = material.map;\n }\n return basicMaterial;\n };\n\n const setBasicMaterialTo = (node: THREE.Object3D): void => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n mesh.material[index] = convertToBasicMaterial(mesh.material[index]);\n }\n } else {\n mesh.material = convertToBasicMaterial(mesh.material);\n }\n };\n\n const traverseToSetBasicMaterialFromMeshes = (node: THREE.Object3D) =>\n node.traverse(setBasicMaterialTo);\n\n class Model3DRuntimeObject3DRenderer extends gdjs.RuntimeObject3DRenderer {\n private _model3DRuntimeObject: gdjs.Model3DRuntimeObject;\n /**\n * The 3D model stretched in a 1x1x1 cube.\n */\n private _threeObject: THREE.Object3D;\n private _originalModel: THREE_ADDONS.GLTF;\n private _animationMixer: THREE.AnimationMixer;\n private _action: THREE.AnimationAction | null;\n\n /**\n * The model origin evaluated according to the object configuration.\n *\n * Coordinates are between 0 and 1.\n */\n private _modelOriginPoint: FloatPoint3D;\n\n constructor(\n runtimeObject: gdjs.Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // GLB files with skeleton must not have any transformation to work properly.\n const originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n // _updateModel will actually add a clone of the model.\n const model = new THREE.Group();\n\n // Create a group to transform the object according to\n // position, angle and dimensions.\n const group = new THREE.Group();\n group.rotation.order = 'ZYX';\n group.add(model);\n super(runtimeObject, instanceContainer, group);\n\n this._model3DRuntimeObject = runtimeObject;\n this._threeObject = model;\n this._originalModel = originalModel;\n this._modelOriginPoint = [0, 0, 0];\n\n this.updateSize();\n this.updatePosition();\n this.updateRotation();\n\n this._animationMixer = new THREE.AnimationMixer(model);\n this._action = null;\n }\n\n updateAnimation(timeDelta: float) {\n this._animationMixer.update(timeDelta);\n }\n\n updatePosition() {\n const originPoint = this.getOriginPoint();\n const centerPoint = this.getCenterPoint();\n this.get3DRendererObject().position.set(\n this._object.getX() -\n this._object.getWidth() * (originPoint[0] - centerPoint[0]),\n this._object.getY() -\n this._object.getHeight() * (originPoint[1] - centerPoint[1]),\n this._object.getZ() -\n this._object.getDepth() * (originPoint[2] - centerPoint[2])\n );\n }\n\n getOriginPoint() {\n return this._model3DRuntimeObject._originPoint || this._modelOriginPoint;\n }\n\n getCenterPoint() {\n return this._model3DRuntimeObject._centerPoint || this._modelOriginPoint;\n }\n\n private _updateDefaultTransformation(\n threeObject: THREE.Object3D,\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // These formulas are also used in:\n // - Model3DEditor.modelSize\n // - Model3DRendered2DInstance\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n threeObject.updateMatrixWorld(true);\n const boundingBox = new THREE.Box3().setFromObject(threeObject);\n\n const shouldKeepModelOrigin = !this._model3DRuntimeObject._originPoint;\n if (shouldKeepModelOrigin) {\n // Keep the origin as part of the model.\n // For instance, a model can be 1 face of a cube and we want to keep the\n // inside as part of the object even if it's just void.\n // It also avoids to have the origin outside of the object box.\n boundingBox.expandByPoint(new THREE.Vector3(0, 0, 0));\n }\n\n const modelWidth = boundingBox.max.x - boundingBox.min.x;\n const modelHeight = boundingBox.max.y - boundingBox.min.y;\n const modelDepth = boundingBox.max.z - boundingBox.min.z;\n this._modelOriginPoint[0] =\n modelWidth < epsilon ? 0 : -boundingBox.min.x / modelWidth;\n this._modelOriginPoint[1] =\n modelHeight < epsilon ? 0 : -boundingBox.min.y / modelHeight;\n this._modelOriginPoint[2] =\n modelDepth < epsilon ? 0 : -boundingBox.min.z / modelDepth;\n\n // The model is flipped on Y axis.\n this._modelOriginPoint[1] = 1 - this._modelOriginPoint[1];\n\n // Center the model.\n const centerPoint = this._model3DRuntimeObject._centerPoint;\n if (centerPoint) {\n threeObject.position.set(\n -(boundingBox.min.x + modelWidth * centerPoint[0]),\n // The model is flipped on Y axis.\n -(boundingBox.min.y + modelHeight * (1 - centerPoint[1])),\n -(boundingBox.min.z + modelDepth * centerPoint[2])\n );\n }\n\n // Rotate the model.\n threeObject.scale.set(1, 1, 1);\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n\n // Stretch the model in a 1x1x1 cube.\n const scaleX = modelWidth < epsilon ? 1 : 1 / modelWidth;\n const scaleY = modelHeight < epsilon ? 1 : 1 / modelHeight;\n const scaleZ = modelDepth < epsilon ? 1 : 1 / modelDepth;\n\n const scaleMatrix = new THREE.Matrix4();\n // Flip on Y because the Y axis is on the opposite side of direct basis.\n // It avoids models to be like a mirror refection.\n scaleMatrix.makeScale(scaleX, -scaleY, scaleZ);\n threeObject.updateMatrix();\n threeObject.applyMatrix4(scaleMatrix);\n\n if (keepAspectRatio) {\n // Reduce the object dimensions to keep aspect ratio.\n const widthRatio =\n modelWidth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalWidth / modelWidth;\n const heightRatio =\n modelHeight < epsilon\n ? Number.POSITIVE_INFINITY\n : originalHeight / modelHeight;\n const depthRatio =\n modelDepth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalDepth / modelDepth;\n let scaleRatio = Math.min(widthRatio, heightRatio, depthRatio);\n if (!Number.isFinite(scaleRatio)) {\n scaleRatio = 1;\n }\n\n this._object._setOriginalWidth(scaleRatio * modelWidth);\n this._object._setOriginalHeight(scaleRatio * modelHeight);\n this._object._setOriginalDepth(scaleRatio * modelDepth);\n }\n }\n\n /**\n * `_updateModel` should always be called after this method.\n * Ideally, use `Model3DRuntimeObject#_reloadModel` instead.\n */\n _reloadModel(\n runtimeObject: Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n }\n\n _updateModel(\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // Start from the original model because:\n // - _replaceMaterials is destructive\n // - _updateDefaultTransformation may need to work with meshes in local space\n\n // This group hold the rotation defined by properties.\n const threeObject = new THREE.Group();\n threeObject.rotation.order = 'ZYX';\n const root = THREE_ADDONS.SkeletonUtils.clone(this._originalModel.scene);\n threeObject.add(root);\n\n this._replaceMaterials(threeObject);\n\n this._updateDefaultTransformation(\n threeObject,\n rotationX,\n rotationY,\n rotationZ,\n originalWidth,\n originalHeight,\n originalDepth,\n keepAspectRatio\n );\n\n // Replace the 3D object.\n this.get3DRendererObject().remove(this._threeObject);\n this.get3DRendererObject().add(threeObject);\n this._threeObject = threeObject;\n\n // Start the current animation on the new 3D object.\n this._animationMixer = new THREE.AnimationMixer(root);\n const isAnimationPaused = this._model3DRuntimeObject.isAnimationPaused();\n this._model3DRuntimeObject.setAnimationIndex(\n this._model3DRuntimeObject.getAnimationIndex()\n );\n if (isAnimationPaused) {\n this.pauseAnimation();\n }\n }\n\n /**\n * Replace materials to better work with lights (or no light).\n */\n private _replaceMaterials(threeObject: THREE.Object3D) {\n if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness\n ) {\n traverseToRemoveMetalnessFromMeshes(threeObject);\n } else if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.Basic\n ) {\n traverseToSetBasicMaterialFromMeshes(threeObject);\n }\n }\n\n getAnimationCount() {\n return this._originalModel.animations.length;\n }\n\n getAnimationName(animationIndex: integer) {\n return this._originalModel.animations[animationIndex].name;\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n if (!this._action) {\n return true;\n }\n return !this._action.isRunning();\n }\n\n animationPaused() {\n if (!this._action) {\n return;\n }\n return this._action.paused;\n }\n\n pauseAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = true;\n }\n\n resumeAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = false;\n }\n\n playAnimation(animationName: string, shouldLoop: boolean) {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n if (!clip) {\n console.error(\n `The GLB file: ${this._model3DRuntimeObject._modelResourceName} doesn't have any animation named: ${animationName}`\n );\n return;\n }\n const previousAction = this._action;\n this._action = this._animationMixer.clipAction(clip);\n this._action.setLoop(\n shouldLoop ? THREE.LoopRepeat : THREE.LoopOnce,\n Number.POSITIVE_INFINITY\n );\n this._action.clampWhenFinished = true;\n\n if (previousAction && previousAction !== this._action) {\n this._action.enabled = true;\n this._action.crossFadeFrom(\n previousAction,\n this._model3DRuntimeObject._crossfadeDuration,\n false\n );\n }\n this._action.play();\n // Make sure the first frame is displayed.\n this._animationMixer.update(0);\n }\n\n getAnimationElapsedTime(): float {\n return this._action ? this._action.time : 0;\n }\n\n setAnimationElapsedTime(time: float): void {\n if (this._action) {\n this._action.time = time;\n }\n }\n\n getAnimationDuration(animationName: string): float {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n return clip ? clip.duration : 0;\n }\n }\n\n export const Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n export type Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAGE,KAAM,GAAU,EAAK,IAAK,IAEpB,EAAkB,AAAC,GAAmC,CAE1D,AAAI,EAAS,WAEX,GAAS,UAAY,IAInB,EAA0B,AAAC,GAAyB,CACxD,KAAM,GAAO,EACb,GAAI,EAAC,EAAK,SAGV,GAAI,MAAM,QAAQ,EAAK,UACrB,OAAS,GAAQ,EAAG,EAAQ,EAAK,SAAS,OAAQ,IAChD,EAAgB,EAAK,SAAS,QAGhC,GAAgB,EAAK,WAInB,EAAsC,AAAC,GAC3C,EAAK,SAAS,GAEV,EAAyB,AAC7B,GAC4B,CAC5B,KAAM,GAAgB,GAAI,OAAM,kBAEhC,MAAI,GAAS,OAEX,GAAc,MAAQ,EAAS,OAG7B,EAAS,KAEX,GAAc,IAAM,EAAS,KAExB,GAGH,EAAqB,AAAC,GAA+B,CACzD,KAAM,GAAO,EACb,GAAI,EAAC,EAAK,SAIV,GAAI,MAAM,QAAQ,EAAK,UACrB,OAAS,GAAQ,EAAG,EAAQ,EAAK,SAAS,OAAQ,IAChD,EAAK,SAAS,GAAS,EAAuB,EAAK,SAAS,QAG9D,GAAK,SAAW,EAAuB,EAAK,WAI1C,EAAuC,AAAC,GAC5C,EAAK,SAAS,GAEhB,eAA6C,GAAK,uBAAwB,CA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Metalness = (material: THREE.Material): void => {\n //@ts-ignore\n if (material.metalness) {\n //@ts-ignore\n material.metalness = 0;\n }\n };\n\n const removeMetalnessFromMesh = (node: THREE.Object3D) => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n removeMetalness(mesh.material[index]);\n }\n } else {\n removeMetalness(mesh.material);\n }\n };\n\n const traverseToRemoveMetalnessFromMeshes = (node: THREE.Object3D) =>\n node.traverse(removeMetalnessFromMesh);\n\n const convertToBasicMaterial = (\n material: THREE.Material\n ): THREE.MeshBasicMaterial => {\n const basicMaterial = new THREE.MeshBasicMaterial();\n //@ts-ignore\n if (material.color) {\n //@ts-ignore\n basicMaterial.color = material.color;\n }\n //@ts-ignore\n if (material.map) {\n //@ts-ignore\n basicMaterial.map = material.map;\n }\n return basicMaterial;\n };\n\n const setBasicMaterialTo = (node: THREE.Object3D): void => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n mesh.material[index] = convertToBasicMaterial(mesh.material[index]);\n }\n } else {\n mesh.material = convertToBasicMaterial(mesh.material);\n }\n };\n\n const traverseToSetBasicMaterialFromMeshes = (node: THREE.Object3D) =>\n node.traverse(setBasicMaterialTo);\n\n class Model3DRuntimeObject3DRenderer extends gdjs.RuntimeObject3DRenderer {\n private _model3DRuntimeObject: gdjs.Model3DRuntimeObject;\n /**\n * The 3D model stretched in a 1x1x1 cube.\n */\n private _threeObject: THREE.Object3D;\n private _originalModel: THREE_ADDONS.GLTF;\n private _animationMixer: THREE.AnimationMixer;\n private _action: THREE.AnimationAction | null;\n\n /**\n * The model origin evaluated according to the object configuration.\n *\n * Coordinates are between 0 and 1.\n */\n private _modelOriginPoint: FloatPoint3D;\n\n constructor(\n runtimeObject: gdjs.Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // GLB files with skeleton must not have any transformation to work properly.\n const originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n // _updateModel will actually add a clone of the model.\n const model = new THREE.Group();\n\n // Create a group to transform the object according to\n // position, angle and dimensions.\n const group = new THREE.Group();\n group.rotation.order = 'ZYX';\n group.add(model);\n super(runtimeObject, instanceContainer, group);\n\n this._model3DRuntimeObject = runtimeObject;\n this._threeObject = model;\n this._originalModel = originalModel;\n this._modelOriginPoint = [0, 0, 0];\n\n this.updateSize();\n this.updatePosition();\n this.updateRotation();\n\n this._animationMixer = new THREE.AnimationMixer(model);\n this._action = null;\n }\n\n updateAnimation(timeDelta: float) {\n this._animationMixer.update(timeDelta);\n }\n\n updatePosition() {\n const originPoint = this.getOriginPoint();\n const centerPoint = this.getCenterPoint();\n this.get3DRendererObject().position.set(\n this._object.getX() -\n this._object.getWidth() * (originPoint[0] - centerPoint[0]),\n this._object.getY() -\n this._object.getHeight() * (originPoint[1] - centerPoint[1]),\n this._object.getZ() -\n this._object.getDepth() * (originPoint[2] - centerPoint[2])\n );\n }\n\n getOriginPoint() {\n return this._model3DRuntimeObject._originPoint || this._modelOriginPoint;\n }\n\n getCenterPoint() {\n return this._model3DRuntimeObject._centerPoint || this._modelOriginPoint;\n }\n\n private _updateDefaultTransformation(\n threeObject: THREE.Object3D,\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // These formulas are also used in:\n // - Model3DEditor.modelSize\n // - Model3DRendered2DInstance\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n threeObject.updateMatrixWorld(true);\n const boundingBox = new THREE.Box3().setFromObject(threeObject);\n\n const shouldKeepModelOrigin = !this._model3DRuntimeObject._originPoint;\n if (shouldKeepModelOrigin) {\n // Keep the origin as part of the model.\n // For instance, a model can be 1 face of a cube and we want to keep the\n // inside as part of the object even if it's just void.\n // It also avoids to have the origin outside of the object box.\n boundingBox.expandByPoint(new THREE.Vector3(0, 0, 0));\n }\n\n const modelWidth = boundingBox.max.x - boundingBox.min.x;\n const modelHeight = boundingBox.max.y - boundingBox.min.y;\n const modelDepth = boundingBox.max.z - boundingBox.min.z;\n this._modelOriginPoint[0] =\n modelWidth < epsilon ? 0 : -boundingBox.min.x / modelWidth;\n this._modelOriginPoint[1] =\n modelHeight < epsilon ? 0 : -boundingBox.min.y / modelHeight;\n this._modelOriginPoint[2] =\n modelDepth < epsilon ? 0 : -boundingBox.min.z / modelDepth;\n\n // The model is flipped on Y axis.\n this._modelOriginPoint[1] = 1 - this._modelOriginPoint[1];\n\n // Center the model.\n const centerPoint = this._model3DRuntimeObject._centerPoint;\n if (centerPoint) {\n threeObject.position.set(\n -(boundingBox.min.x + modelWidth * centerPoint[0]),\n // The model is flipped on Y axis.\n -(boundingBox.min.y + modelHeight * (1 - centerPoint[1])),\n -(boundingBox.min.z + modelDepth * centerPoint[2])\n );\n }\n\n // Rotate the model.\n threeObject.scale.set(1, 1, 1);\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n\n // Stretch the model in a 1x1x1 cube.\n const scaleX = modelWidth < epsilon ? 1 : 1 / modelWidth;\n const scaleY = modelHeight < epsilon ? 1 : 1 / modelHeight;\n const scaleZ = modelDepth < epsilon ? 1 : 1 / modelDepth;\n\n const scaleMatrix = new THREE.Matrix4();\n // Flip on Y because the Y axis is on the opposite side of direct basis.\n // It avoids models to be like a mirror refection.\n scaleMatrix.makeScale(scaleX, -scaleY, scaleZ);\n threeObject.updateMatrix();\n threeObject.applyMatrix4(scaleMatrix);\n\n if (keepAspectRatio) {\n // Reduce the object dimensions to keep aspect ratio.\n const widthRatio =\n modelWidth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalWidth / modelWidth;\n const heightRatio =\n modelHeight < epsilon\n ? Number.POSITIVE_INFINITY\n : originalHeight / modelHeight;\n const depthRatio =\n modelDepth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalDepth / modelDepth;\n let scaleRatio = Math.min(widthRatio, heightRatio, depthRatio);\n if (!Number.isFinite(scaleRatio)) {\n scaleRatio = 1;\n }\n\n this._object._setOriginalWidth(scaleRatio * modelWidth);\n this._object._setOriginalHeight(scaleRatio * modelHeight);\n this._object._setOriginalDepth(scaleRatio * modelDepth);\n }\n }\n\n /**\n * `_updateModel` should always be called after this method.\n * Ideally, use `Model3DRuntimeObject#_reloadModel` instead.\n */\n _reloadModel(\n runtimeObject: Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n }\n\n _updateModel(\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // Start from the original model because:\n // - _replaceMaterials is destructive\n // - _updateDefaultTransformation may need to work with meshes in local space\n\n // This group hold the rotation defined by properties.\n const threeObject = new THREE.Group();\n threeObject.rotation.order = 'ZYX';\n const root = THREE_ADDONS.SkeletonUtils.clone(this._originalModel.scene);\n threeObject.add(root);\n\n this._replaceMaterials(threeObject);\n\n this._updateDefaultTransformation(\n threeObject,\n rotationX,\n rotationY,\n rotationZ,\n originalWidth,\n originalHeight,\n originalDepth,\n keepAspectRatio\n );\n\n // Replace the 3D object.\n this.get3DRendererObject().remove(this._threeObject);\n this.get3DRendererObject().add(threeObject);\n this._threeObject = threeObject;\n\n // Start the current animation on the new 3D object.\n this._animationMixer = new THREE.AnimationMixer(root);\n const isAnimationPaused = this._model3DRuntimeObject.isAnimationPaused();\n this._model3DRuntimeObject.setAnimationIndex(\n this._model3DRuntimeObject.getAnimationIndex()\n );\n if (isAnimationPaused) {\n this.pauseAnimation();\n }\n }\n\n /**\n * Replace materials to better work with lights (or no light).\n */\n private _replaceMaterials(threeObject: THREE.Object3D) {\n if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness\n ) {\n traverseToRemoveMetalnessFromMeshes(threeObject);\n } else if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.Basic\n ) {\n traverseToSetBasicMaterialFromMeshes(threeObject);\n }\n }\n\n getAnimationCount() {\n return this._originalModel.animations.length;\n }\n\n getAnimationName(animationIndex: integer) {\n return this._originalModel.animations[animationIndex].name;\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n if (!this._action) {\n return true;\n }\n return !this._action.isRunning();\n }\n\n animationPaused() {\n if (!this._action) {\n return;\n }\n return this._action.paused;\n }\n\n pauseAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = true;\n }\n\n resumeAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = false;\n }\n\n playAnimation(animationName: string, shouldLoop: boolean) {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n if (!clip) {\n console.error(\n `The GLB file: ${this._model3DRuntimeObject._modelResourceName} doesn't have any animation named: ${animationName}`\n );\n return;\n }\n const previousAction = this._action;\n this._action = this._animationMixer.clipAction(clip);\n // Reset the animation and play it from the start.\n // `clipAction` always gives back the same action for a given animation\n // and its likely to be in a finished or at least started state.\n this._action.reset();\n this._action.setLoop(\n shouldLoop ? THREE.LoopRepeat : THREE.LoopOnce,\n Number.POSITIVE_INFINITY\n );\n this._action.clampWhenFinished = true;\n this._action.timeScale =\n this._model3DRuntimeObject.getAnimationSpeedScale();\n\n if (previousAction && previousAction !== this._action) {\n this._action.crossFadeFrom(\n previousAction,\n this._model3DRuntimeObject._crossfadeDuration,\n false\n );\n }\n this._action.play();\n // Make sure the first frame is displayed.\n this._animationMixer.update(0);\n }\n\n getAnimationElapsedTime(): float {\n return this._action ? this._action.time : 0;\n }\n\n setAnimationElapsedTime(time: float): void {\n if (this._action) {\n this._action.time = time;\n }\n }\n\n setAnimationTimeScale(timeScale: float): void {\n if (this._action) {\n this._action.timeScale = timeScale;\n }\n }\n\n getAnimationDuration(animationName: string): float {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n return clip ? clip.duration : 0;\n }\n }\n\n export const Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n export type Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAGE,KAAM,GAAU,EAAK,IAAK,IAEpB,EAAkB,AAAC,GAAmC,CAE1D,AAAI,EAAS,WAEX,GAAS,UAAY,IAInB,EAA0B,AAAC,GAAyB,CACxD,KAAM,GAAO,EACb,GAAI,EAAC,EAAK,SAGV,GAAI,MAAM,QAAQ,EAAK,UACrB,OAAS,GAAQ,EAAG,EAAQ,EAAK,SAAS,OAAQ,IAChD,EAAgB,EAAK,SAAS,QAGhC,GAAgB,EAAK,WAInB,EAAsC,AAAC,GAC3C,EAAK,SAAS,GAEV,EAAyB,AAC7B,GAC4B,CAC5B,KAAM,GAAgB,GAAI,OAAM,kBAEhC,MAAI,GAAS,OAEX,GAAc,MAAQ,EAAS,OAG7B,EAAS,KAEX,GAAc,IAAM,EAAS,KAExB,GAGH,EAAqB,AAAC,GAA+B,CACzD,KAAM,GAAO,EACb,GAAI,EAAC,EAAK,SAIV,GAAI,MAAM,QAAQ,EAAK,UACrB,OAAS,GAAQ,EAAG,EAAQ,EAAK,SAAS,OAAQ,IAChD,EAAK,SAAS,GAAS,EAAuB,EAAK,SAAS,QAG9D,GAAK,SAAW,EAAuB,EAAK,WAI1C,EAAuC,AAAC,GAC5C,EAAK,SAAS,GAEhB,eAA6C,GAAK,uBAAwB,CAiBxE,YACE,EACA,EACA,CA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AAK,QAAQ,UACX,KAAK,sBAAsB,yBAEzB,GAAkB,IAAmB,KAAK,SAC5C,KAAK,QAAQ,cACX,EACA,KAAK,sBAAsB,mBAC3B,IAGJ,KAAK,QAAQ,OAEb,KAAK,gBAAgB,OAAO,GAG9B,yBAAiC,CAC/B,MAAO,MAAK,QAAU,KAAK,QAAQ,KAAO,EAG5C,wBAAwB,EAAmB,CACzC,AAAI,KAAK,SACP,MAAK,QAAQ,KAAO,GAIxB,sBAAsB,EAAwB,CAC5C,AAAI,KAAK,SACP,MAAK,QAAQ,UAAY,GAI7B,qBAAqB,EAA8B,CACjD,KAAM,GAAO,MAAM,cAAc,WAC/B,KAAK,eAAe,WACpB,GAEF,MAAO,GAAO,EAAK,SAAW,GAI3B,AAAM,+BAA+B,IAtapC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(a){let i;(function(t){t[t.None=0]="None",t[t.WindowLeft=1]="WindowLeft",t[t.WindowRight=2]="WindowRight",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(i||(i={}));let n;(function(t){t[t.None=0]="None",t[t.WindowTop=1]="WindowTop",t[t.WindowBottom=2]="WindowBottom",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(n||(n={}));class D extends a.RuntimeBehavior{constructor(e,o,r){super(e,o,r);this._useLegacyBottomAndRightAnchors=!1;this._hasJustBeenCreated=!0;this._leftEdgeDistance=0;this._rightEdgeDistance=0;this._topEdgeDistance=0;this._bottomEdgeDistance=0;this._oldDrawableX=0;this._oldDrawableY=0;this._oldWidth=0;this._oldHeight=0;this._parentOldMinX=0;this._parentOldMinY=0;this._parentOldMaxX=0;this._parentOldMaxY=0;this._relativeToOriginalWindowSize=!!o.relativeToOriginalWindowSize,this._leftEdgeAnchor=o.leftEdgeAnchor,this._rightEdgeAnchor=o.rightEdgeAnchor,this._topEdgeAnchor=o.topEdgeAnchor,this._bottomEdgeAnchor=o.bottomEdgeAnchor,this._useLegacyBottomAndRightAnchors=o.useLegacyBottomAndRightAnchors===void 0?!0:o.useLegacyBottomAndRightAnchors}updateFromBehaviorData(e,o){return e.leftEdgeAnchor!==o.leftEdgeAnchor&&(this._leftEdgeAnchor=o.leftEdgeAnchor),e.rightEdgeAnchor!==o.rightEdgeAnchor&&(this._rightEdgeAnchor=o.rightEdgeAnchor),e.topEdgeAnchor!==o.topEdgeAnchor&&(this._topEdgeAnchor=o.topEdgeAnchor),e.bottomEdgeAnchor!==o.bottomEdgeAnchor&&(this._bottomEdgeAnchor=o.bottomEdgeAnchor),e.useLegacyTrajectory!==o.useLegacyTrajectory&&(this._useLegacyBottomAndRightAnchors=o.useLegacyBottomAndRightAnchors),e.relativeToOriginalWindowSize===o.relativeToOriginalWindowSize}doStepPreEvents(e){(this._oldDrawableX!==this.owner.getDrawableX()||this._oldDrawableY!==this.owner.getDrawableY()||this._oldWidth!==this.owner.getWidth()||this._oldHeight!==this.owner.getHeight())&&this._updateAnchorDistances(e),(this._parentOldMinX!==e.getUnrotatedViewportMinX()||this._parentOldMinY!==e.getUnrotatedViewportMinY()||this._parentOldMaxX!==e.getUnrotatedViewportMaxX()||this._parentOldMaxY!==e.getUnrotatedViewportMaxY())&&this._followAnchor(e)}_updateAnchorDistances(e){const o=a.staticArray(a.AnchorRuntimeBehavior.prototype.doStepPreEvents),r=e.getLayer(this.owner.getLayer());let s=this._parentOldMinX,t=this._parentOldMinY,d=this._parentOldMaxX,l=this._parentOldMaxY;this._hasJustBeenCreated&&(this._relativeToOriginalWindowSize?(s=e.getInitialUnrotatedViewportMinX(),t=e.getInitialUnrotatedViewportMinY(),d=e.getInitialUnrotatedViewportMaxX(),l=e.getInitialUnrotatedViewportMaxY()):(s=e.getUnrotatedViewportMinX(),t=e.getUnrotatedViewportMinY(),d=e.getUnrotatedViewportMaxX(),l=e.getUnrotatedViewportMaxY()));const w=(d+s)/2,p=(l+t)/2,f=d-s,E=l-t,h=this._relativeToOriginalWindowSize?[this.owner.getDrawableX(),this.owner.getDrawableY()]:this._convertInverseCoords(e,r,this.owner.getDrawableX(),this.owner.getDrawableY(),o);this._leftEdgeAnchor===1?this._leftEdgeDistance=h[0]-s:this._leftEdgeAnchor===2?this._leftEdgeDistance=h[0]-d:this._leftEdgeAnchor===3?this._leftEdgeDistance=(h[0]-s)/f:this._leftEdgeAnchor===4&&(this._leftEdgeDistance=h[0]-w),this._topEdgeAnchor===1?this._topEdgeDistance=h[1]-t:this._topEdgeAnchor===2?this._topEdgeDistance=h[1]-l:this._topEdgeAnchor===3?this._topEdgeDistance=(h[1]-t)/E:this._topEdgeAnchor===4&&(this._topEdgeDistance=h[1]-p);const g=this._relativeToOriginalWindowSize?[this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight()]:this._convertInverseCoords(e,r,this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight(),o);this._rightEdgeAnchor===1?this._rightEdgeDistance=g[0]-s:this._rightEdgeAnchor===2?this._rightEdgeDistance=g[0]-d:this._rightEdgeAnchor===3?this._rightEdgeDistance=(g[0]-s)/f:this._rightEdgeAnchor===4&&(this._rightEdgeDistance=g[0]-w),this._bottomEdgeAnchor===1?this._bottomEdgeDistance=g[1]-t:this._bottomEdgeAnchor===2?this._bottomEdgeDistance=g[1]-l:this._bottomEdgeAnchor===3?this._bottomEdgeDistance=(g[1]-t)/E:this._bottomEdgeAnchor===4&&(this._bottomEdgeDistance=g[1]-p),this._hasJustBeenCreated=!1}_followAnchor(e){const o=a.staticArray(a.AnchorRuntimeBehavior.prototype.doStepPreEvents),r=e.getLayer(this.owner.getLayer());let s=e.getUnrotatedViewportMinX(),t=e.getUnrotatedViewportMinY(),d=e.getUnrotatedViewportMaxX(),l=e.getUnrotatedViewportMaxY();const w=(d+s)/2,p=(l+t)/2,f=d-s,E=l-t;let h=0,g=0,A=0,m=0;this._leftEdgeAnchor===1?h=s+this._leftEdgeDistance:this._leftEdgeAnchor===2?h=d+this._leftEdgeDistance:this._leftEdgeAnchor===3?h=s+this._leftEdgeDistance*f:this._leftEdgeAnchor===4&&(h=w+this._leftEdgeDistance),this._topEdgeAnchor===1?g=t+this._topEdgeDistance:this._topEdgeAnchor===2?g=l+this._topEdgeDistance:this._topEdgeAnchor===3?g=t+this._topEdgeDistance*E:this._topEdgeAnchor===4&&(g=p+this._topEdgeDistance),this._rightEdgeAnchor===1?A=s+this._rightEdgeDistance:this._rightEdgeAnchor===2?A=d+this._rightEdgeDistance:this._rightEdgeAnchor===3?A=s+this._rightEdgeDistance*f:this._rightEdgeAnchor===4&&(A=w+this._rightEdgeDistance),this._bottomEdgeAnchor===1?m=t+this._bottomEdgeDistance:this._bottomEdgeAnchor===2?m=l+this._bottomEdgeDistance:this._bottomEdgeAnchor===3?m=t+this._bottomEdgeDistance*E:this._bottomEdgeAnchor===4&&(m=p+this._bottomEdgeDistance);const Y=this._convertCoords(e,r,h,g,o);let _=Y[0],c=Y[1];const M=this._convertCoords(e,r,A,m,o),W=M[0],X=M[1];if(this._useLegacyBottomAndRightAnchors)this._rightEdgeAnchor!==0&&this.owner.setWidth(W-_),this._bottomEdgeAnchor!==0&&this.owner.setHeight(X-c),this._leftEdgeAnchor!==0&&this.owner.setX(_+this.owner.getX()-this.owner.getDrawableX()),this._topEdgeAnchor!==0&&this.owner.setY(c+this.owner.getY()-this.owner.getDrawableY());else{if(this._rightEdgeAnchor!==0&&this._leftEdgeAnchor!==0){const b=W-_;this.owner.setX(this.owner.getX()===this.owner.getDrawableX()?_:_+(this.owner.getX()-this.owner.getDrawableX())*b/this.owner.getWidth()),this.owner.setWidth(b)}else this._leftEdgeAnchor!==0&&this.owner.setX(_+this.owner.getX()-this.owner.getDrawableX()),this._rightEdgeAnchor!==0&&this.owner.setX(W+this.owner.getX()-this.owner.getDrawableX()-this.owner.getWidth());if(this._bottomEdgeAnchor!==0&&this._topEdgeAnchor!==0){const b=X-c;this.owner.setY(this.owner.getY()===this.owner.getDrawableY()?c:c+(this.owner.getY()-this.owner.getDrawableY())*b/this.owner.getHeight()),this.owner.setHeight(b)}else this._topEdgeAnchor!==0&&this.owner.setY(c+this.owner.getY()-this.owner.getDrawableY()),this._bottomEdgeAnchor!==0&&this.owner.setY(X+this.owner.getY()-this.owner.getDrawableY()-this.owner.getHeight())
|
|
1
|
+
var gdjs;(function(a){let i;(function(t){t[t.None=0]="None",t[t.WindowLeft=1]="WindowLeft",t[t.WindowRight=2]="WindowRight",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(i||(i={}));let n;(function(t){t[t.None=0]="None",t[t.WindowTop=1]="WindowTop",t[t.WindowBottom=2]="WindowBottom",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(n||(n={}));class D extends a.RuntimeBehavior{constructor(e,o,r){super(e,o,r);this._useLegacyBottomAndRightAnchors=!1;this._hasJustBeenCreated=!0;this._leftEdgeDistance=0;this._rightEdgeDistance=0;this._topEdgeDistance=0;this._bottomEdgeDistance=0;this._oldDrawableX=0;this._oldDrawableY=0;this._oldWidth=0;this._oldHeight=0;this._parentOldMinX=0;this._parentOldMinY=0;this._parentOldMaxX=0;this._parentOldMaxY=0;this._relativeToOriginalWindowSize=!!o.relativeToOriginalWindowSize,this._leftEdgeAnchor=o.leftEdgeAnchor,this._rightEdgeAnchor=o.rightEdgeAnchor,this._topEdgeAnchor=o.topEdgeAnchor,this._bottomEdgeAnchor=o.bottomEdgeAnchor,this._useLegacyBottomAndRightAnchors=o.useLegacyBottomAndRightAnchors===void 0?!0:o.useLegacyBottomAndRightAnchors}updateFromBehaviorData(e,o){return e.leftEdgeAnchor!==o.leftEdgeAnchor&&(this._leftEdgeAnchor=o.leftEdgeAnchor),e.rightEdgeAnchor!==o.rightEdgeAnchor&&(this._rightEdgeAnchor=o.rightEdgeAnchor),e.topEdgeAnchor!==o.topEdgeAnchor&&(this._topEdgeAnchor=o.topEdgeAnchor),e.bottomEdgeAnchor!==o.bottomEdgeAnchor&&(this._bottomEdgeAnchor=o.bottomEdgeAnchor),e.useLegacyTrajectory!==o.useLegacyTrajectory&&(this._useLegacyBottomAndRightAnchors=o.useLegacyBottomAndRightAnchors),e.relativeToOriginalWindowSize===o.relativeToOriginalWindowSize}doStepPreEvents(e){(this._oldDrawableX!==this.owner.getDrawableX()||this._oldDrawableY!==this.owner.getDrawableY()||this._oldWidth!==this.owner.getWidth()||this._oldHeight!==this.owner.getHeight())&&this._updateAnchorDistances(e),(this._parentOldMinX!==e.getUnrotatedViewportMinX()||this._parentOldMinY!==e.getUnrotatedViewportMinY()||this._parentOldMaxX!==e.getUnrotatedViewportMaxX()||this._parentOldMaxY!==e.getUnrotatedViewportMaxY())&&this._followAnchor(e)}_updateAnchorDistances(e){const o=a.staticArray(a.AnchorRuntimeBehavior.prototype.doStepPreEvents),r=e.getLayer(this.owner.getLayer());let s=this._parentOldMinX,t=this._parentOldMinY,d=this._parentOldMaxX,l=this._parentOldMaxY;this._hasJustBeenCreated&&(this._relativeToOriginalWindowSize?(s=e.getInitialUnrotatedViewportMinX(),t=e.getInitialUnrotatedViewportMinY(),d=e.getInitialUnrotatedViewportMaxX(),l=e.getInitialUnrotatedViewportMaxY()):(s=e.getUnrotatedViewportMinX(),t=e.getUnrotatedViewportMinY(),d=e.getUnrotatedViewportMaxX(),l=e.getUnrotatedViewportMaxY()));const w=(d+s)/2,p=(l+t)/2,f=d-s,E=l-t,h=this._relativeToOriginalWindowSize?[this.owner.getDrawableX(),this.owner.getDrawableY()]:this._convertInverseCoords(e,r,this.owner.getDrawableX(),this.owner.getDrawableY(),o);this._leftEdgeAnchor===1?this._leftEdgeDistance=h[0]-s:this._leftEdgeAnchor===2?this._leftEdgeDistance=h[0]-d:this._leftEdgeAnchor===3?this._leftEdgeDistance=(h[0]-s)/f:this._leftEdgeAnchor===4&&(this._leftEdgeDistance=h[0]-w),this._topEdgeAnchor===1?this._topEdgeDistance=h[1]-t:this._topEdgeAnchor===2?this._topEdgeDistance=h[1]-l:this._topEdgeAnchor===3?this._topEdgeDistance=(h[1]-t)/E:this._topEdgeAnchor===4&&(this._topEdgeDistance=h[1]-p);const g=this._relativeToOriginalWindowSize?[this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight()]:this._convertInverseCoords(e,r,this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight(),o);this._rightEdgeAnchor===1?this._rightEdgeDistance=g[0]-s:this._rightEdgeAnchor===2?this._rightEdgeDistance=g[0]-d:this._rightEdgeAnchor===3?this._rightEdgeDistance=(g[0]-s)/f:this._rightEdgeAnchor===4&&(this._rightEdgeDistance=g[0]-w),this._bottomEdgeAnchor===1?this._bottomEdgeDistance=g[1]-t:this._bottomEdgeAnchor===2?this._bottomEdgeDistance=g[1]-l:this._bottomEdgeAnchor===3?this._bottomEdgeDistance=(g[1]-t)/E:this._bottomEdgeAnchor===4&&(this._bottomEdgeDistance=g[1]-p),this._hasJustBeenCreated=!1}_followAnchor(e){const o=a.staticArray(a.AnchorRuntimeBehavior.prototype.doStepPreEvents),r=e.getLayer(this.owner.getLayer());let s=e.getUnrotatedViewportMinX(),t=e.getUnrotatedViewportMinY(),d=e.getUnrotatedViewportMaxX(),l=e.getUnrotatedViewportMaxY();const w=(d+s)/2,p=(l+t)/2,f=d-s,E=l-t;let h=0,g=0,A=0,m=0;this._leftEdgeAnchor===1?h=s+this._leftEdgeDistance:this._leftEdgeAnchor===2?h=d+this._leftEdgeDistance:this._leftEdgeAnchor===3?h=s+this._leftEdgeDistance*f:this._leftEdgeAnchor===4&&(h=w+this._leftEdgeDistance),this._topEdgeAnchor===1?g=t+this._topEdgeDistance:this._topEdgeAnchor===2?g=l+this._topEdgeDistance:this._topEdgeAnchor===3?g=t+this._topEdgeDistance*E:this._topEdgeAnchor===4&&(g=p+this._topEdgeDistance),this._rightEdgeAnchor===1?A=s+this._rightEdgeDistance:this._rightEdgeAnchor===2?A=d+this._rightEdgeDistance:this._rightEdgeAnchor===3?A=s+this._rightEdgeDistance*f:this._rightEdgeAnchor===4&&(A=w+this._rightEdgeDistance),this._bottomEdgeAnchor===1?m=t+this._bottomEdgeDistance:this._bottomEdgeAnchor===2?m=l+this._bottomEdgeDistance:this._bottomEdgeAnchor===3?m=t+this._bottomEdgeDistance*E:this._bottomEdgeAnchor===4&&(m=p+this._bottomEdgeDistance);const Y=this._convertCoords(e,r,h,g,o);let _=Y[0],c=Y[1];const M=this._convertCoords(e,r,A,m,o),W=M[0],X=M[1];if(this._useLegacyBottomAndRightAnchors)this._rightEdgeAnchor!==0&&this.owner.setWidth(W-_),this._bottomEdgeAnchor!==0&&this.owner.setHeight(X-c),this._leftEdgeAnchor!==0&&this.owner.setX(_+this.owner.getX()-this.owner.getDrawableX()),this._topEdgeAnchor!==0&&this.owner.setY(c+this.owner.getY()-this.owner.getDrawableY());else{if(this._rightEdgeAnchor!==0&&this._leftEdgeAnchor!==0){const b=W-_;this.owner.setX(this.owner.getX()===this.owner.getDrawableX()?_:_+(this.owner.getX()-this.owner.getDrawableX())*b/this.owner.getWidth()),this.owner.setWidth(b)}else this._leftEdgeAnchor!==0&&this.owner.setX(_+this.owner.getX()-this.owner.getDrawableX()),this._rightEdgeAnchor!==0&&this.owner.setX(W+this.owner.getX()-this.owner.getDrawableX()-this.owner.getWidth());if(this._bottomEdgeAnchor!==0&&this._topEdgeAnchor!==0){const b=X-c;this.owner.setY(this.owner.getY()===this.owner.getDrawableY()?c:c+(this.owner.getY()-this.owner.getDrawableY())*b/this.owner.getHeight()),this.owner.setHeight(b)}else this._topEdgeAnchor!==0&&this.owner.setY(c+this.owner.getY()-this.owner.getDrawableY()),this._bottomEdgeAnchor!==0&&this.owner.setY(X+this.owner.getY()-this.owner.getDrawableY()-this.owner.getHeight())}this._oldDrawableX=this.owner.getDrawableX(),this._oldDrawableY=this.owner.getDrawableY(),this._oldWidth=this.owner.getWidth(),this._oldHeight=this.owner.getHeight(),this._parentOldMinX=e.getUnrotatedViewportMinX(),this._parentOldMinY=e.getUnrotatedViewportMinY(),this._parentOldMaxX=e.getUnrotatedViewportMaxX(),this._parentOldMaxY=e.getUnrotatedViewportMaxY()}doStepPostEvents(e){}_convertCoords(e,o,r,s,t){return e!==e.getScene()?(t[0]=r,t[1]=s,t):o.convertCoords(r,s,0,t)}_convertInverseCoords(e,o,r,s,t){return e!==e.getScene()?(t[0]=r,t[1]=s,t):o.convertInverseCoords(r,s,0,t)}}a.AnchorRuntimeBehavior=D,a.registerBehavior("AnchorBehavior::AnchorBehavior",a.AnchorRuntimeBehavior)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=anchorruntimebehavior.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/AnchorBehavior/anchorruntimebehavior.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nGDevelop - Anchor Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n const enum HorizontalAnchor {\n None = 0,\n WindowLeft,\n WindowRight,\n Proportional,\n WindowCenter,\n }\n const enum VerticalAnchor {\n None = 0,\n WindowTop,\n WindowBottom,\n Proportional,\n WindowCenter,\n }\n\n export class AnchorRuntimeBehavior extends gdjs.RuntimeBehavior {\n // Configuration\n\n _relativeToOriginalWindowSize: boolean;\n _leftEdgeAnchor: HorizontalAnchor;\n _rightEdgeAnchor: HorizontalAnchor;\n _topEdgeAnchor: VerticalAnchor;\n _bottomEdgeAnchor: VerticalAnchor;\n _useLegacyBottomAndRightAnchors: boolean = false;\n\n // State\n\n _hasJustBeenCreated: boolean = true;\n _leftEdgeDistance: float = 0;\n _rightEdgeDistance: float = 0;\n _topEdgeDistance: float = 0;\n _bottomEdgeDistance: float = 0;\n\n _oldDrawableX: float = 0;\n _oldDrawableY: float = 0;\n _oldWidth: float = 0;\n _oldHeight: float = 0;\n\n _parentOldMinX: float = 0;\n _parentOldMinY: float = 0;\n _parentOldMaxX: float = 0;\n _parentOldMaxY: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._relativeToOriginalWindowSize =\n !!behaviorData.relativeToOriginalWindowSize;\n this._leftEdgeAnchor = behaviorData.leftEdgeAnchor;\n this._rightEdgeAnchor = behaviorData.rightEdgeAnchor;\n this._topEdgeAnchor = behaviorData.topEdgeAnchor;\n this._bottomEdgeAnchor = behaviorData.bottomEdgeAnchor;\n this._useLegacyBottomAndRightAnchors =\n behaviorData.useLegacyBottomAndRightAnchors === undefined\n ? true\n : behaviorData.useLegacyBottomAndRightAnchors;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.leftEdgeAnchor !== newBehaviorData.leftEdgeAnchor) {\n this._leftEdgeAnchor = newBehaviorData.leftEdgeAnchor;\n }\n if (oldBehaviorData.rightEdgeAnchor !== newBehaviorData.rightEdgeAnchor) {\n this._rightEdgeAnchor = newBehaviorData.rightEdgeAnchor;\n }\n if (oldBehaviorData.topEdgeAnchor !== newBehaviorData.topEdgeAnchor) {\n this._topEdgeAnchor = newBehaviorData.topEdgeAnchor;\n }\n if (\n oldBehaviorData.bottomEdgeAnchor !== newBehaviorData.bottomEdgeAnchor\n ) {\n this._bottomEdgeAnchor = newBehaviorData.bottomEdgeAnchor;\n }\n if (\n oldBehaviorData.useLegacyTrajectory !==\n newBehaviorData.useLegacyTrajectory\n ) {\n this._useLegacyBottomAndRightAnchors =\n newBehaviorData.useLegacyBottomAndRightAnchors;\n }\n if (\n oldBehaviorData.relativeToOriginalWindowSize !==\n newBehaviorData.relativeToOriginalWindowSize\n ) {\n return false;\n }\n return true;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const objectHasMoved =\n this._oldDrawableX !== this.owner.getDrawableX() ||\n this._oldDrawableY !== this.owner.getDrawableY() ||\n this._oldWidth !== this.owner.getWidth() ||\n this._oldHeight !== this.owner.getHeight();\n if (objectHasMoved) {\n this._updateAnchorDistances(instanceContainer);\n }\n const parentHasResized =\n this._parentOldMinX !== instanceContainer.getUnrotatedViewportMinX() ||\n this._parentOldMinY !== instanceContainer.getUnrotatedViewportMinY() ||\n this._parentOldMaxX !== instanceContainer.getUnrotatedViewportMaxX() ||\n this._parentOldMaxY !== instanceContainer.getUnrotatedViewportMaxY();\n if (parentHasResized) {\n this._followAnchor(instanceContainer);\n }\n }\n\n private _updateAnchorDistances(\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n\n let parentMinX = this._parentOldMinX;\n let parentMinY = this._parentOldMinY;\n let parentMaxX = this._parentOldMaxX;\n let parentMaxY = this._parentOldMaxY;\n if (this._hasJustBeenCreated) {\n if (this._relativeToOriginalWindowSize) {\n parentMinX = instanceContainer.getInitialUnrotatedViewportMinX();\n parentMinY = instanceContainer.getInitialUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getInitialUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getInitialUnrotatedViewportMaxY();\n } else {\n parentMinX = instanceContainer.getUnrotatedViewportMinX();\n parentMinY = instanceContainer.getUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n }\n }\n const parentCenterX = (parentMaxX + parentMinX) / 2;\n const parentCenterY = (parentMaxY + parentMinY) / 2;\n const parentWidth = parentMaxX - parentMinX;\n const parentHeight = parentMaxY - parentMinY;\n\n //Calculate the distances from the window's bounds.\n const topLeftPixel = this._relativeToOriginalWindowSize\n ? [this.owner.getDrawableX(), this.owner.getDrawableY()]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX(),\n this.owner.getDrawableY(),\n workingPoint\n );\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMinX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMaxX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n this._leftEdgeDistance = (topLeftPixel[0] - parentMinX) / parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._leftEdgeDistance = topLeftPixel[0] - parentCenterX;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n this._topEdgeDistance = topLeftPixel[1] - parentMinY;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._topEdgeDistance = topLeftPixel[1] - parentMaxY;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n this._topEdgeDistance = (topLeftPixel[1] - parentMinY) / parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._topEdgeDistance = topLeftPixel[1] - parentCenterY;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const bottomRightPixel = this._relativeToOriginalWindowSize\n ? [\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n ]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n workingPoint\n );\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMinX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMaxX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n this._rightEdgeDistance =\n (bottomRightPixel[0] - parentMinX) / parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentCenterX;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMinY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMaxY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n this._bottomEdgeDistance =\n (bottomRightPixel[1] - parentMinY) / parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentCenterY;\n }\n\n this._hasJustBeenCreated = false;\n }\n\n private _followAnchor(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n\n let parentMinX = instanceContainer.getUnrotatedViewportMinX();\n let parentMinY = instanceContainer.getUnrotatedViewportMinY();\n let parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n let parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n const parentCenterX = (parentMaxX + parentMinX) / 2;\n const parentCenterY = (parentMaxY + parentMinY) / 2;\n const parentWidth = parentMaxX - parentMinX;\n const parentHeight = parentMaxY - parentMinY;\n\n //Move and resize the object if needed\n let leftPixel = 0;\n let topPixel = 0;\n let rightPixel = 0;\n let bottomPixel = 0;\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n leftPixel = parentMinX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n leftPixel = parentMaxX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n leftPixel = parentMinX + this._leftEdgeDistance * parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n leftPixel = parentCenterX + this._leftEdgeDistance;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n topPixel = parentMinY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n topPixel = parentMaxY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n topPixel = parentMinY + this._topEdgeDistance * parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n topPixel = parentCenterY + this._topEdgeDistance;\n }\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n rightPixel = parentMinX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n rightPixel = parentMaxX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n rightPixel = parentMinX + this._rightEdgeDistance * parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n rightPixel = parentCenterX + this._rightEdgeDistance;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n bottomPixel = parentMinY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n bottomPixel = parentMaxY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n bottomPixel = parentMinY + this._bottomEdgeDistance * parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n bottomPixel = parentCenterY + this._bottomEdgeDistance;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const topLeftCoord = this._convertCoords(\n instanceContainer,\n layer,\n leftPixel,\n topPixel,\n workingPoint\n );\n let left = topLeftCoord[0];\n let top = topLeftCoord[1];\n\n const bottomRightCoord = this._convertCoords(\n instanceContainer,\n layer,\n rightPixel,\n bottomPixel,\n workingPoint\n );\n const right = bottomRightCoord[0];\n const bottom = bottomRightCoord[1];\n\n // Compatibility with GD <= 5.0.133\n if (this._useLegacyBottomAndRightAnchors) {\n //Move and resize the object according to the anchors\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setWidth(right - left);\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setHeight(bottom - top);\n }\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(left + this.owner.getX() - this.owner.getDrawableX());\n }\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(top + this.owner.getY() - this.owner.getDrawableY());\n }\n }\n // End of compatibility code\n else {\n // Resize if right and left anchors are set\n if (\n this._rightEdgeAnchor !== HorizontalAnchor.None &&\n this._leftEdgeAnchor !== HorizontalAnchor.None\n ) {\n const width = right - left;\n this.owner.setX(\n this.owner.getX() === this.owner.getDrawableX()\n ? left\n : // It uses the position of the origin relatively to the object\n // size to apply it with the new size.\n // This is the same as doing:\n // lerp(left, right, (this.owner.getX() - this.owner.getDrawableX() / this.owner.getWidth())\n // But, the division is done at the end to avoid rounding errors.\n left +\n ((this.owner.getX() - this.owner.getDrawableX()) * width) /\n this.owner.getWidth()\n );\n this.owner.setWidth(width);\n } else {\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n right +\n this.owner.getX() -\n this.owner.getDrawableX() -\n this.owner.getWidth()\n );\n }\n }\n\n // Resize if top and bottom anchors are set\n if (\n this._bottomEdgeAnchor !== VerticalAnchor.None &&\n this._topEdgeAnchor !== VerticalAnchor.None\n ) {\n const height = bottom - top;\n this.owner.setY(\n this.owner.getY() === this.owner.getDrawableY()\n ? top\n : top +\n ((this.owner.getY() - this.owner.getDrawableY()) * height) /\n this.owner.getHeight()\n );\n this.owner.setHeight(height);\n } else {\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n bottom +\n this.owner.getY() -\n this.owner.getDrawableY() -\n this.owner.getHeight()\n );\n }\n }\n this._oldDrawableX = this.owner.getDrawableX();\n this._oldDrawableY = this.owner.getDrawableY();\n this._oldWidth = this.owner.getWidth();\n this._oldHeight = this.owner.getHeight();\n\n this._parentOldMinX = instanceContainer.getUnrotatedViewportMinX();\n this._parentOldMinY = instanceContainer.getUnrotatedViewportMinY();\n this._parentOldMaxX = instanceContainer.getUnrotatedViewportMaxX();\n this._parentOldMaxY = instanceContainer.getUnrotatedViewportMaxY();\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}\n\n private _convertCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertCoords(x, y, 0, result);\n }\n\n private _convertInverseCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertInverseCoords(x, y, 0, result);\n }\n }\n gdjs.registerBehavior(\n 'AnchorBehavior::AnchorBehavior',\n gdjs.AnchorRuntimeBehavior\n );\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,GAAW,GAAX,UAAW,EAAX,CACE,SAAO,GAAP,OACA,+BACA,iCACA,mCACA,q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MAAK,MAAM,OAAS,KAAK,MAAM,gBAAkB,EACjD,KAAK,MAAM,YAErB,KAAK,MAAM,SAAS,OAEpB,AAAI,MAAK,kBAAoB,GAC3B,KAAK,MAAM,KACT,EAAO,KAAK,MAAM,OAAS,KAAK,MAAM,gBAGtC,KAAK,mBAAqB,GAC5B,KAAK,MAAM,KACT,EACE,KAAK,MAAM,OACX,KAAK,MAAM,eACX,KAAK,MAAM,YAMnB,GACE,KAAK,oBAAsB,GAC3B,KAAK,iBAAmB,EACxB,CACA,KAAM,GAAS,EAAS,EACxB,KAAK,MAAM,KACT,KAAK,MAAM,SAAW,KAAK,MAAM,eAC7B,EACA,EACI,MAAK,MAAM,OAAS,KAAK,MAAM,gBAAkB,EACjD,KAAK,MAAM,aAErB,KAAK,MAAM,UAAU,OAErB,AAAI,MAAK,iBAAmB,GAC1B,KAAK,MAAM,KACT,EAAM,KAAK,MAAM,OAAS,KAAK,MAAM,gBAGrC,KAAK,oBAAsB,GAC7B,KAAK,MAAM,KACT,EACE,KAAK,MAAM,OACX,KAAK,MAAM,eACX,KAAK,MAAM,
|
|
4
|
+
"sourcesContent": ["/*\nGDevelop - Anchor Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n const enum HorizontalAnchor {\n None = 0,\n WindowLeft,\n WindowRight,\n Proportional,\n WindowCenter,\n }\n const enum VerticalAnchor {\n None = 0,\n WindowTop,\n WindowBottom,\n Proportional,\n WindowCenter,\n }\n\n export class AnchorRuntimeBehavior extends gdjs.RuntimeBehavior {\n // Configuration\n\n _relativeToOriginalWindowSize: boolean;\n _leftEdgeAnchor: HorizontalAnchor;\n _rightEdgeAnchor: HorizontalAnchor;\n _topEdgeAnchor: VerticalAnchor;\n _bottomEdgeAnchor: VerticalAnchor;\n _useLegacyBottomAndRightAnchors: boolean = false;\n\n // State\n\n _hasJustBeenCreated: boolean = true;\n _leftEdgeDistance: float = 0;\n _rightEdgeDistance: float = 0;\n _topEdgeDistance: float = 0;\n _bottomEdgeDistance: float = 0;\n\n _oldDrawableX: float = 0;\n _oldDrawableY: float = 0;\n _oldWidth: float = 0;\n _oldHeight: float = 0;\n\n _parentOldMinX: float = 0;\n _parentOldMinY: float = 0;\n _parentOldMaxX: float = 0;\n _parentOldMaxY: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._relativeToOriginalWindowSize =\n !!behaviorData.relativeToOriginalWindowSize;\n this._leftEdgeAnchor = behaviorData.leftEdgeAnchor;\n this._rightEdgeAnchor = behaviorData.rightEdgeAnchor;\n this._topEdgeAnchor = behaviorData.topEdgeAnchor;\n this._bottomEdgeAnchor = behaviorData.bottomEdgeAnchor;\n this._useLegacyBottomAndRightAnchors =\n behaviorData.useLegacyBottomAndRightAnchors === undefined\n ? true\n : behaviorData.useLegacyBottomAndRightAnchors;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.leftEdgeAnchor !== newBehaviorData.leftEdgeAnchor) {\n this._leftEdgeAnchor = newBehaviorData.leftEdgeAnchor;\n }\n if (oldBehaviorData.rightEdgeAnchor !== newBehaviorData.rightEdgeAnchor) {\n this._rightEdgeAnchor = newBehaviorData.rightEdgeAnchor;\n }\n if (oldBehaviorData.topEdgeAnchor !== newBehaviorData.topEdgeAnchor) {\n this._topEdgeAnchor = newBehaviorData.topEdgeAnchor;\n }\n if (\n oldBehaviorData.bottomEdgeAnchor !== newBehaviorData.bottomEdgeAnchor\n ) {\n this._bottomEdgeAnchor = newBehaviorData.bottomEdgeAnchor;\n }\n if (\n oldBehaviorData.useLegacyTrajectory !==\n newBehaviorData.useLegacyTrajectory\n ) {\n this._useLegacyBottomAndRightAnchors =\n newBehaviorData.useLegacyBottomAndRightAnchors;\n }\n if (\n oldBehaviorData.relativeToOriginalWindowSize !==\n newBehaviorData.relativeToOriginalWindowSize\n ) {\n return false;\n }\n return true;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const objectHasMoved =\n this._oldDrawableX !== this.owner.getDrawableX() ||\n this._oldDrawableY !== this.owner.getDrawableY() ||\n this._oldWidth !== this.owner.getWidth() ||\n this._oldHeight !== this.owner.getHeight();\n if (objectHasMoved) {\n this._updateAnchorDistances(instanceContainer);\n }\n const parentHasResized =\n this._parentOldMinX !== instanceContainer.getUnrotatedViewportMinX() ||\n this._parentOldMinY !== instanceContainer.getUnrotatedViewportMinY() ||\n this._parentOldMaxX !== instanceContainer.getUnrotatedViewportMaxX() ||\n this._parentOldMaxY !== instanceContainer.getUnrotatedViewportMaxY();\n if (parentHasResized) {\n this._followAnchor(instanceContainer);\n }\n }\n\n private _updateAnchorDistances(\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n\n let parentMinX = this._parentOldMinX;\n let parentMinY = this._parentOldMinY;\n let parentMaxX = this._parentOldMaxX;\n let parentMaxY = this._parentOldMaxY;\n if (this._hasJustBeenCreated) {\n if (this._relativeToOriginalWindowSize) {\n parentMinX = instanceContainer.getInitialUnrotatedViewportMinX();\n parentMinY = instanceContainer.getInitialUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getInitialUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getInitialUnrotatedViewportMaxY();\n } else {\n parentMinX = instanceContainer.getUnrotatedViewportMinX();\n parentMinY = instanceContainer.getUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n }\n }\n const parentCenterX = (parentMaxX + parentMinX) / 2;\n const parentCenterY = (parentMaxY + parentMinY) / 2;\n const parentWidth = parentMaxX - parentMinX;\n const parentHeight = parentMaxY - parentMinY;\n\n //Calculate the distances from the window's bounds.\n const topLeftPixel = this._relativeToOriginalWindowSize\n ? [this.owner.getDrawableX(), this.owner.getDrawableY()]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX(),\n this.owner.getDrawableY(),\n workingPoint\n );\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMinX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMaxX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n this._leftEdgeDistance = (topLeftPixel[0] - parentMinX) / parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._leftEdgeDistance = topLeftPixel[0] - parentCenterX;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n this._topEdgeDistance = topLeftPixel[1] - parentMinY;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._topEdgeDistance = topLeftPixel[1] - parentMaxY;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n this._topEdgeDistance = (topLeftPixel[1] - parentMinY) / parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._topEdgeDistance = topLeftPixel[1] - parentCenterY;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const bottomRightPixel = this._relativeToOriginalWindowSize\n ? [\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n ]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n workingPoint\n );\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMinX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMaxX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n this._rightEdgeDistance =\n (bottomRightPixel[0] - parentMinX) / parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentCenterX;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMinY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMaxY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n this._bottomEdgeDistance =\n (bottomRightPixel[1] - parentMinY) / parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentCenterY;\n }\n\n this._hasJustBeenCreated = false;\n }\n\n private _followAnchor(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n\n let parentMinX = instanceContainer.getUnrotatedViewportMinX();\n let parentMinY = instanceContainer.getUnrotatedViewportMinY();\n let parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n let parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n const parentCenterX = (parentMaxX + parentMinX) / 2;\n const parentCenterY = (parentMaxY + parentMinY) / 2;\n const parentWidth = parentMaxX - parentMinX;\n const parentHeight = parentMaxY - parentMinY;\n\n //Move and resize the object if needed\n let leftPixel = 0;\n let topPixel = 0;\n let rightPixel = 0;\n let bottomPixel = 0;\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n leftPixel = parentMinX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n leftPixel = parentMaxX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n leftPixel = parentMinX + this._leftEdgeDistance * parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n leftPixel = parentCenterX + this._leftEdgeDistance;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n topPixel = parentMinY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n topPixel = parentMaxY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n topPixel = parentMinY + this._topEdgeDistance * parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n topPixel = parentCenterY + this._topEdgeDistance;\n }\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n rightPixel = parentMinX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n rightPixel = parentMaxX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n rightPixel = parentMinX + this._rightEdgeDistance * parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n rightPixel = parentCenterX + this._rightEdgeDistance;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n bottomPixel = parentMinY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n bottomPixel = parentMaxY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n bottomPixel = parentMinY + this._bottomEdgeDistance * parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n bottomPixel = parentCenterY + this._bottomEdgeDistance;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const topLeftCoord = this._convertCoords(\n instanceContainer,\n layer,\n leftPixel,\n topPixel,\n workingPoint\n );\n let left = topLeftCoord[0];\n let top = topLeftCoord[1];\n\n const bottomRightCoord = this._convertCoords(\n instanceContainer,\n layer,\n rightPixel,\n bottomPixel,\n workingPoint\n );\n const right = bottomRightCoord[0];\n const bottom = bottomRightCoord[1];\n\n // Compatibility with GD <= 5.0.133\n if (this._useLegacyBottomAndRightAnchors) {\n //Move and resize the object according to the anchors\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setWidth(right - left);\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setHeight(bottom - top);\n }\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(left + this.owner.getX() - this.owner.getDrawableX());\n }\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(top + this.owner.getY() - this.owner.getDrawableY());\n }\n }\n // End of compatibility code\n else {\n // Resize if right and left anchors are set\n if (\n this._rightEdgeAnchor !== HorizontalAnchor.None &&\n this._leftEdgeAnchor !== HorizontalAnchor.None\n ) {\n const width = right - left;\n this.owner.setX(\n this.owner.getX() === this.owner.getDrawableX()\n ? left\n : // It uses the position of the origin relatively to the object\n // size to apply it with the new size.\n // This is the same as doing:\n // lerp(left, right, (this.owner.getX() - this.owner.getDrawableX() / this.owner.getWidth())\n // But, the division is done at the end to avoid rounding errors.\n left +\n ((this.owner.getX() - this.owner.getDrawableX()) * width) /\n this.owner.getWidth()\n );\n this.owner.setWidth(width);\n } else {\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n right +\n this.owner.getX() -\n this.owner.getDrawableX() -\n this.owner.getWidth()\n );\n }\n }\n\n // Resize if top and bottom anchors are set\n if (\n this._bottomEdgeAnchor !== VerticalAnchor.None &&\n this._topEdgeAnchor !== VerticalAnchor.None\n ) {\n const height = bottom - top;\n this.owner.setY(\n this.owner.getY() === this.owner.getDrawableY()\n ? top\n : top +\n ((this.owner.getY() - this.owner.getDrawableY()) * height) /\n this.owner.getHeight()\n );\n this.owner.setHeight(height);\n } else {\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n bottom +\n this.owner.getY() -\n this.owner.getDrawableY() -\n this.owner.getHeight()\n );\n }\n }\n }\n this._oldDrawableX = this.owner.getDrawableX();\n this._oldDrawableY = this.owner.getDrawableY();\n this._oldWidth = this.owner.getWidth();\n this._oldHeight = this.owner.getHeight();\n\n this._parentOldMinX = instanceContainer.getUnrotatedViewportMinX();\n this._parentOldMinY = instanceContainer.getUnrotatedViewportMinY();\n this._parentOldMaxX = instanceContainer.getUnrotatedViewportMaxX();\n this._parentOldMaxY = instanceContainer.getUnrotatedViewportMaxY();\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}\n\n private _convertCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertCoords(x, y, 0, result);\n }\n\n private _convertInverseCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertInverseCoords(x, y, 0, result);\n }\n }\n gdjs.registerBehavior(\n 'AnchorBehavior::AnchorBehavior',\n gdjs.AnchorRuntimeBehavior\n );\n}\n"],
|
|
5
|
+
"mapp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B,EAAkB,WAExC,GAAO,GAAK,EACZ,EAAO,GAAK,EACL,GAEF,EAAM,qBAAqB,EAAG,EAAG,EAAG,IA7ZxC,EAAM,wBAgab,EAAK,iBACH,iCACA,EAAK,yBAlbC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -20,8 +20,8 @@ module.exports = {
|
|
|
20
20
|
extension
|
|
21
21
|
.setExtensionInformation(
|
|
22
22
|
'Physics2',
|
|
23
|
-
_('Physics Engine
|
|
24
|
-
"The physics engine simulates realistic object physics, with gravity, forces, joints, etc. It's perfect for games that need to have realistic behaving objects and a gameplay centered around it.",
|
|
23
|
+
_('2D Physics Engine'),
|
|
24
|
+
"The 2D physics engine simulates realistic object physics, with gravity, forces, collisions, joints, etc. It's perfect for 2D games that need to have realistic behaving objects and a gameplay centered around it.",
|
|
25
25
|
'Florian Rival, Franco Maciel',
|
|
26
26
|
'MIT'
|
|
27
27
|
)
|
|
@@ -515,10 +515,10 @@ module.exports = {
|
|
|
515
515
|
// extension
|
|
516
516
|
.addBehavior(
|
|
517
517
|
'Physics2Behavior',
|
|
518
|
-
_('Physics Engine
|
|
518
|
+
_('2D Physics Engine'),
|
|
519
519
|
'Physics2',
|
|
520
520
|
_(
|
|
521
|
-
'Simulate realistic
|
|
521
|
+
'Simulate realistic 2D physics for the object including gravity, forces, collisions, and joints.'
|
|
522
522
|
),
|
|
523
523
|
'',
|
|
524
524
|
'res/physics32.png',
|