gdcore-tools 2.0.0-beta5 → 2.0.0-beta6
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/CustomRuntimeObject.js +1 -1
- package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
- package/dist/Runtime/Extensions/AdMob/admobtools.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/Effects/JsExtension.js +2 -2
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +97 -7
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +62 -27
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/JsExtension.js +32 -0
- 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/Extensions/Spine/spineruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/JsExtension.js +3 -1
- package/dist/Runtime/Extensions/TileMap/JsExtension.js +84 -29
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +12 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +1 -0
- package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
- package/dist/Runtime/SpriteAnimator.js +1 -1
- package/dist/Runtime/SpriteAnimator.js.map +2 -2
- package/dist/Runtime/debugger-client/InGameDebugger.js +1 -1
- package/dist/Runtime/debugger-client/InGameDebugger.js.map +2 -2
- package/dist/Runtime/debugger-client/abstract-debugger-client.js +1 -1
- package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
- package/dist/Runtime/debugger-client/hot-reloader.js +2 -1
- package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
- package/dist/Runtime/debugger-client/minimal-debugger-client.js +2 -0
- package/dist/Runtime/debugger-client/minimal-debugger-client.js.map +7 -0
- package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
- package/dist/Runtime/debugger-client/window-message-debugger-client.js.map +2 -2
- package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/runtimescene.js +1 -1
- package/dist/Runtime/runtimescene.js.map +2 -2
- package/dist/Runtime/scenestack.js +1 -1
- package/dist/Runtime/scenestack.js.map +2 -2
- package/dist/Runtime/spriteruntimeobject.js +1 -1
- package/dist/Runtime/spriteruntimeobject.js.map +2 -2
- package/dist/Runtime/types/project-data.d.ts +31 -8
- package/dist/Runtime/variablescontainer.js +1 -1
- package/dist/Runtime/variablescontainer.js.map +2 -2
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +77 -47
- package/package.json +2 -2
- package/dist/lib/libGD.d.cts +0 -5
- package/dist/loaders.d.cts +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(a){class o extends a.RuntimeObject{constructor(t,e){super(t,e);this._isUntransformedHitBoxesDirty=!0;this._untransformedHitBoxes=[];this._unrotatedAABB={min:[0,0],max:[0,0]};this._forcedDefaultSize=null;this._scaleX=1;this._scaleY=1;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._customCenter=null;this._localTransformation=new a.AffineTransformation;this._localInverseTransformation=new a.AffineTransformation;this._isLocalTransformationDirty=!0;this._instanceContainer=new a.CustomRuntimeObjectInstanceContainer(t,this),this._renderer=this._createRender(),this._createDefaultSizeIfNeeded(e),this._instanceContainer.loadFrom(e)}reinitialize(t){super.reinitialize(t),this._createDefaultSizeIfNeeded(t),this._instanceContainer.loadFrom(t),this._reinitializeRenderer(),this.onCreated()}_createDefaultSizeIfNeeded(t){t.instances.length>0&&(t.defaultSize||(t.defaultSize={min:[t.areaMinX,t.areaMinY,t.areaMinZ],max:[t.areaMaxX,t.areaMaxY,t.areaMaxZ]}),this._forcedDefaultSize=t.defaultSize)}updateFromObjectData(t,e){const i=this.getAnimator();return i&&i.updateFromObjectData(t.animatable||[],e.animatable||[]),this._instanceContainer.updateFrom(t,e)}extraInitializationFromInitialInstance(t){const e=this.getAnimator();if(t.numberProperties)for(let i=0,s=t.numberProperties.length;i<s;++i){const n=t.numberProperties[i];e&&n.name==="animation"&&e.setAnimationIndex(n.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height))}onDeletedFromScene(t){this.onDestroy(t),super.onDeletedFromScene(t),this._instanceContainer.onDestroyFromScene(t)}update(t){this._instanceContainer._updateObjectsPreEvents(),this.doStepPreEvents(this._instanceContainer);const e=this.getRuntimeScene().getProfiler();e&&e.begin(this.type),this.doStepPostEvents(this._instanceContainer),e&&e.end(this.type),this._instanceContainer._updateObjectsPostEvents()}onHotReloading(t){}doStepPreEvents(t){}doStepPostEvents(t){}onDestroy(t){}updatePreRender(t){this._instanceContainer._updateObjectsPreRender(),this.getRenderer().ensureUpToDate()}getRenderer(){return this._renderer}onChildrenLocationChanged(){this._isUntransformedHitBoxesDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()}updateHitBoxes(){this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes();const t=this.getLocalTransformation();for(let e=0;e<this._untransformedHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new a.Polygon);for(let i=0;i<this._untransformedHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),t.transform(this._untransformedHitBoxes[e].vertices[i],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=this._untransformedHitBoxes[e].vertices.length}}_updateUntransformedHitBoxes(){this._isUntransformedHitBoxesDirty=!1,this._untransformedHitBoxes.length=0;let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=-Number.MAX_VALUE,s=-Number.MAX_VALUE;for(const n of this._instanceContainer.getAdhocListOfAllInstances()){if(!n.isIncludedInParentCollisionMask())continue;Array.prototype.push.apply(this._untransformedHitBoxes,n.getHitBoxes());const r=n.getAABB();t=Math.min(t,r.min[0]),e=Math.min(e,r.min[1]),i=Math.max(i,r.max[0]),s=Math.max(s,r.max[1])}for(t===Number.MAX_VALUE&&(t=0,e=0,i=1,s=1),this._unrotatedAABB.min[0]=t,this._unrotatedAABB.min[1]=e,this._unrotatedAABB.max[0]=i,this._unrotatedAABB.max[1]=s;this.hitBoxes.length<this._untransformedHitBoxes.length;)this.hitBoxes.push(new a.Polygon);this.hitBoxes.length=this._untransformedHitBoxes.length}applyObjectTransformation(t,e,i){const s=i;s[0]=t,s[1]=e,this.getLocalTransformation().transform(s,i)}getLocalTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localTransformation}getLocalInverseTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localInverseTransformation}_updateLocalTransformation(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY),i=this.getUnscaledCenterX()*t,s=this.getUnscaledCenterY()*e,n=this.angle*Math.PI/180;this._localTransformation.setToTranslation(this.x,this.y),this._localTransformation.rotateAround(n,i,s),this._flippedX&&this._localTransformation.flipX(i),this._flippedY&&this._localTransformation.flipY(s),this._localTransformation.scale(t,e),this._localInverseTransformation.copyFrom(this._localTransformation),this._localInverseTransformation.invert(),this._isLocalTransformationDirty=!1}applyObjectInverseTransformation(t,e,i){const s=i;s[0]=t,s[1]=e,this.getLocalInverseTransformation().transform(s,i)}getDrawableX(){let t=0;this._forcedDefaultSize?t=this._forcedDefaultSize.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[0]);const e=this.getScaleX();return this._flippedX?this.x+(-t-this.getUnscaledWidth()+2*this.getUnscaledCenterX())*e:this.x+t*e}getDrawableY(){let t=0;this._forcedDefaultSize?t=this._forcedDefaultSize.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[1]);const e=this.getScaleY();return this._flippedY?this.y+(-t-this.getUnscaledHeight()+2*this.getUnscaledCenterY())*e:this.y+t*e}getUnscaledWidth(){return this._forcedDefaultSize?this._forcedDefaultSize.max[0]-this._forcedDefaultSize.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[0]-this._unrotatedAABB.min[0])}getUnscaledHeight(){return this._forcedDefaultSize?this._forcedDefaultSize.max[1]-this._forcedDefaultSize.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[1]-this._unrotatedAABB.min[1])}getUnscaledCenterX(){return this._customCenter?this._customCenter[0]:this._forcedDefaultSize?(this._forcedDefaultSize.min[0]+this._forcedDefaultSize.max[0])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[0]+this._unrotatedAABB.max[0])/2)}getUnscaledCenterY(){return this._customCenter?this._customCenter[1]:this._forcedDefaultSize?(this._forcedDefaultSize.min[1]+this._forcedDefaultSize.max[1])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[1]+this._unrotatedAABB.max[1])/2)}setRotationCenter(t,e){this._customCenter||(this._customCenter=[0,0]),this._customCenter[0]=t,this._customCenter[1]=e,this._isLocalTransformationDirty=!0,this.invalidateHitboxes()}hasCustomRotationCenter(){return!!this._customCenter}getCenterX(){return(this.getUnscaledCenterX()-this._unrotatedAABB.min[0])*this.getScaleX()}getCenterY(){return(this.getUnscaledCenterY()-this._unrotatedAABB.min[1])*this.getScaleY()}getWidth(){return this.getUnscaledWidth()*this.getScaleX()}getHeight(){return this.getUnscaledHeight()*this.getScaleY()}setWidth(t){const e=this.getUnscaledWidth();e!==0&&this.setScaleX(t/e)}setHeight(t){const e=this.getUnscaledHeight();e!==0&&this.setScaleY(t/e)}setSize(t,e){this.setWidth(t),this.setHeight(e)}setX(t){t!==this.x&&(this.x=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateX())}setY(t){t!==this.y&&(this.y=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateY())}setAngle(t){this.angle!==t&&(this.angle=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateAngle())}setScale(t){t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update())}setScaleX(t){t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update())}setScaleY(t){t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this.invalidateHitboxes(),this.getRenderer().update())}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this.getRenderer().updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this.getRenderer().updateVisibility()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this.getRenderer().update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this.getRenderer().update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getAnimator(){return null}}a.CustomRuntimeObject=o,o.supportsReinitialization=!1})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(r){const o=new r.Logger("CustomRuntimeObject");class h extends r.RuntimeObject{constructor(t,e){super(t,e);this._isUntransformedHitBoxesDirty=!0;this._untransformedHitBoxes=[];this._unrotatedAABB={min:[0,0],max:[0,0]};this._innerArea=null;this._isInnerAreaFollowingParentSize=!1;this._scaleX=1;this._scaleY=1;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._customCenter=null;this._localTransformation=new r.AffineTransformation;this._localInverseTransformation=new r.AffineTransformation;this._isLocalTransformationDirty=!0;this._type=e.type,this._instanceContainer=new r.CustomRuntimeObjectInstanceContainer(t,this),this._renderer=this._createRender(),this._initializeFromObjectData(e)}_initializeFromObjectData(t){const e=this._runtimeScene.getGame().getEventsBasedObjectData(t.type);if(!e){o.error(`A CustomRuntimeObject was initialized (or re-initialized) from object data referring to an non existing events based object data with type "${t.type}".`);return}this._isInnerAreaFollowingParentSize=e.isInnerAreaFollowingParentSize,e.instances.length>0&&(this._innerArea||(this._innerArea={min:[0,0,0],max:[0,0,0]}),this._innerArea.min[0]=e.areaMinX,this._innerArea.min[1]=e.areaMinY,this._innerArea.min[2]=e.areaMinZ,this._innerArea.max[0]=e.areaMaxX,this._innerArea.max[1]=e.areaMaxY,this._innerArea.max[2]=e.areaMaxZ),this._instanceContainer.loadFrom(t,e)}reinitialize(t){super.reinitialize(t),this._initializeFromObjectData(t),this._reinitializeRenderer(),this.onCreated()}updateFromObjectData(t,e){const i=this.getAnimator();return i&&i.updateFromObjectData(t.animatable||[],e.animatable||[]),!0}extraInitializationFromInitialInstance(t){const e=this.getAnimator();if(t.numberProperties)for(let i=0,n=t.numberProperties.length;i<n;++i){const s=t.numberProperties[i];e&&s.name==="animation"&&e.setAnimationIndex(s.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height))}onDeletedFromScene(t){this.onDestroy(t),super.onDeletedFromScene(t),this._instanceContainer.onDestroyFromScene(t)}update(t){this._instanceContainer._updateObjectsPreEvents(),this.doStepPreEvents(this._instanceContainer);const e=this.getRuntimeScene().getProfiler();e&&e.begin(this.type),this.doStepPostEvents(this._instanceContainer),e&&e.end(this.type),this._instanceContainer._updateObjectsPostEvents()}onHotReloading(t){}doStepPreEvents(t){}doStepPostEvents(t){}onDestroy(t){}updatePreRender(t){this._instanceContainer._updateObjectsPreRender(),this.getRenderer().ensureUpToDate()}getRenderer(){return this._renderer}getChildrenContainer(){return this._instanceContainer}onChildrenLocationChanged(){this._isUntransformedHitBoxesDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()}updateHitBoxes(){this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes();const t=this.getLocalTransformation();for(let e=0;e<this._untransformedHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new r.Polygon);for(let i=0;i<this._untransformedHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),t.transform(this._untransformedHitBoxes[e].vertices[i],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=this._untransformedHitBoxes[e].vertices.length}}_updateUntransformedHitBoxes(){this._isUntransformedHitBoxesDirty=!1,this._untransformedHitBoxes.length=0;let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=-Number.MAX_VALUE,n=-Number.MAX_VALUE;for(const s of this._instanceContainer.getAdhocListOfAllInstances()){if(!s.isIncludedInParentCollisionMask())continue;Array.prototype.push.apply(this._untransformedHitBoxes,s.getHitBoxes());const a=s.getAABB();t=Math.min(t,a.min[0]),e=Math.min(e,a.min[1]),i=Math.max(i,a.max[0]),n=Math.max(n,a.max[1])}for(t===Number.MAX_VALUE&&(t=0,e=0,i=1,n=1),this._unrotatedAABB.min[0]=t,this._unrotatedAABB.min[1]=e,this._unrotatedAABB.max[0]=i,this._unrotatedAABB.max[1]=n;this.hitBoxes.length<this._untransformedHitBoxes.length;)this.hitBoxes.push(new r.Polygon);this.hitBoxes.length=this._untransformedHitBoxes.length}applyObjectTransformation(t,e,i){const n=i;n[0]=t,n[1]=e,this.getLocalTransformation().transform(n,i)}getLocalTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localTransformation}getLocalInverseTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localInverseTransformation}_updateLocalTransformation(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY),i=this.getUnscaledCenterX()*t,n=this.getUnscaledCenterY()*e,s=this.angle*Math.PI/180;this._localTransformation.setToTranslation(this.x,this.y),this._localTransformation.rotateAround(s,i,n),this._flippedX&&this._localTransformation.flipX(i),this._flippedY&&this._localTransformation.flipY(n),this._localTransformation.scale(t,e),this._localInverseTransformation.copyFrom(this._localTransformation),this._localInverseTransformation.invert(),this._isLocalTransformationDirty=!1}applyObjectInverseTransformation(t,e,i){const n=i;n[0]=t,n[1]=e,this.getLocalInverseTransformation().transform(n,i)}getDrawableX(){let t=0;this._innerArea?t=this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[0]);const e=this.getScaleX();return this._flippedX?this.x+(-t-this.getUnscaledWidth()+2*this.getUnscaledCenterX())*e:this.x+t*e}getDrawableY(){let t=0;this._innerArea?t=this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[1]);const e=this.getScaleY();return this._flippedY?this.y+(-t-this.getUnscaledHeight()+2*this.getUnscaledCenterY())*e:this.y+t*e}getInnerAreaMinX(){return this._innerArea?this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.min[0])}getInnerAreaMinY(){return this._innerArea?this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.min[1])}getInnerAreaMaxX(){return this._innerArea?this._innerArea.max[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[0])}getInnerAreaMaxY(){return this._innerArea?this._innerArea.max[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[1])}getUnscaledWidth(){return this._innerArea?this._innerArea.max[0]-this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[0]-this._unrotatedAABB.min[0])}getUnscaledHeight(){return this._innerArea?this._innerArea.max[1]-this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[1]-this._unrotatedAABB.min[1])}getUnscaledCenterX(){return this._customCenter?this._customCenter[0]:this._innerArea?(this._innerArea.min[0]+this._innerArea.max[0])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[0]+this._unrotatedAABB.max[0])/2)}getUnscaledCenterY(){return this._customCenter?this._customCenter[1]:this._innerArea?(this._innerArea.min[1]+this._innerArea.max[1])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[1]+this._unrotatedAABB.max[1])/2)}setRotationCenter(t,e){this._customCenter||(this._customCenter=[0,0]),this._customCenter[0]=t,this._customCenter[1]=e,this._isLocalTransformationDirty=!0,this.invalidateHitboxes()}hasCustomRotationCenter(){return!!this._customCenter}getCenterX(){return(this.getUnscaledCenterX()-this._unrotatedAABB.min[0])*this.getScaleX()}getCenterY(){return(this.getUnscaledCenterY()-this._unrotatedAABB.min[1])*this.getScaleY()}getWidth(){return this.getUnscaledWidth()*this.getScaleX()}getHeight(){return this.getUnscaledHeight()*this.getScaleY()}setWidth(t){const e=this.getUnscaledWidth();if(e===0)return;const i=t/e;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[0]*=i,this._innerArea.max[0]*=i):this.setScaleX(i)}setHeight(t){const e=this.getUnscaledHeight();if(e===0)return;const i=t/e;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[1]*=i,this._innerArea.max[1]*=i):this.setScaleY(i)}setSize(t,e){this.setWidth(t),this.setHeight(e)}setX(t){t!==this.x&&(this.x=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateX())}setY(t){t!==this.y&&(this.y=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateY())}setAngle(t){this.angle!==t&&(this.angle=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateAngle())}setScale(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()))}setScaleX(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()))}setScaleY(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this.invalidateHitboxes(),this.getRenderer().update()))}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this.getRenderer().updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this.getRenderer().updateVisibility()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this.getRenderer().update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this.getRenderer().update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getAnimator(){return null}}r.CustomRuntimeObject=h,h.supportsReinitialization=!1})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=CustomRuntimeObject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/CustomRuntimeObject.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n export type ObjectConfiguration = {\n content: any;\n };\n\n export type CustomObjectConfiguration = ObjectConfiguration & {\n animatable?: SpriteAnimationData[];\n childrenContent: { [objectName: string]: ObjectConfiguration & any };\n instances: InstanceData[];\n layers: LayerData[];\n // The flat representation of defaultSize.\n areaMinX: float;\n areaMinY: float;\n areaMinZ: float;\n areaMaxX: float;\n areaMaxY: float;\n areaMaxZ: float;\n /**\n * A value shared by every object instances.\n *\n * @see gdjs.CustomRuntimeObject._forcedDefaultSize\n **/\n defaultSize: {\n min: [float, float, float];\n max: [float, float, float];\n } | null;\n };\n\n /**\n * An object that contains other object.\n *\n * This is the base class for objects generated from EventsBasedObject.\n *\n * @see gdjs.CustomRuntimeObjectInstanceContainer\n */\n export abstract class CustomRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.OpacityHandler {\n _renderer:\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n /** It contains the children of this object. */\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _isUntransformedHitBoxesDirty: boolean = true;\n /** It contains shallow copies of the children hitboxes */\n private _untransformedHitBoxes: gdjs.Polygon[] = [];\n /** The dimension of this object is calculated from its children AABBs. */\n private _unrotatedAABB: AABB = { min: [0, 0], max: [0, 0] };\n /**\n * The default size defined by users in the custom object initial instances editor.\n *\n * Don't modify it as it would affect every instance.\n **/\n private _forcedDefaultSize: {\n min: [float, float, float];\n max: [float, float, float];\n } | null = null;\n private _scaleX: float = 1;\n private _scaleY: float = 1;\n private _flippedX: boolean = false;\n private _flippedY: boolean = false;\n private opacity: float = 255;\n private _customCenter: FloatPoint | null = null;\n private _localTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n private _localInverseTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n private _isLocalTransformationDirty: boolean = true;\n\n /**\n * @param parent The container the object belongs to\n * @param objectData The object data used to initialize the object\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: ObjectData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._instanceContainer = new gdjs.CustomRuntimeObjectInstanceContainer(\n parent,\n this\n );\n this._renderer = this._createRender();\n\n this._createDefaultSizeIfNeeded(objectData);\n this._instanceContainer.loadFrom(objectData);\n\n // The generated code calls onCreated at the constructor end\n // and onCreated calls its super implementation at its end.\n }\n\n protected abstract _createRender():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n protected abstract _reinitializeRenderer(): void;\n\n reinitialize(objectData: ObjectData & CustomObjectConfiguration) {\n super.reinitialize(objectData);\n\n this._createDefaultSizeIfNeeded(objectData);\n this._instanceContainer.loadFrom(objectData);\n this._reinitializeRenderer();\n\n // The generated code calls the onCreated super implementation at the end.\n this.onCreated();\n }\n\n /**\n * Initialize `defaultSize` if it doesn't exist.\n * `defaultSize` is shared by every instance to save memory.\n */\n private _createDefaultSizeIfNeeded(objectData: CustomObjectConfiguration) {\n if (objectData.instances.length > 0) {\n if (!objectData.defaultSize) {\n objectData.defaultSize = {\n min: [\n objectData.areaMinX,\n objectData.areaMinY,\n objectData.areaMinZ,\n ],\n max: [\n objectData.areaMaxX,\n objectData.areaMaxY,\n objectData.areaMaxZ,\n ],\n };\n }\n this._forcedDefaultSize = objectData.defaultSize;\n }\n }\n\n updateFromObjectData(\n oldObjectData: ObjectData & CustomObjectConfiguration,\n newObjectData: ObjectData & CustomObjectConfiguration\n ): boolean {\n const animator = this.getAnimator();\n if (animator) {\n animator.updateFromObjectData(\n oldObjectData.animatable || [],\n newObjectData.animatable || []\n );\n }\n return this._instanceContainer.updateFrom(oldObjectData, newObjectData);\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n const animator = this.getAnimator();\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (animator && extraData.name === 'animation') {\n animator.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n onDeletedFromScene(parent: gdjs.RuntimeInstanceContainer): void {\n // Let subclasses do something before the object is destroyed.\n this.onDestroy(parent);\n // Let behaviors do something before the object is destroyed.\n super.onDeletedFromScene(parent);\n // Destroy the children.\n this._instanceContainer.onDestroyFromScene(parent);\n }\n\n update(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreEvents();\n\n this.doStepPreEvents(this._instanceContainer);\n\n const profiler = this.getRuntimeScene().getProfiler();\n if (profiler) {\n profiler.begin(this.type);\n }\n // This is a bit like the \"scene\" events for custom objects.\n this.doStepPostEvents(this._instanceContainer);\n if (profiler) {\n profiler.end(this.type);\n }\n\n this._instanceContainer._updateObjectsPostEvents();\n }\n\n /**\n * This method is called when the preview is being hot-reloaded.\n */\n onHotReloading(parent: gdjs.RuntimeInstanceContainer) {}\n\n // This is only to handle trigger once.\n doStepPreEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called each tick after events are done.\n * @param parent The instanceContainer owning the object\n */\n doStepPostEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called when the object is being removed from its parent\n * container and is about to be destroyed/reused later.\n */\n onDestroy(parent: gdjs.RuntimeInstanceContainer) {}\n\n updatePreRender(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreRender();\n this.getRenderer().ensureUpToDate();\n }\n\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._renderer;\n }\n\n onChildrenLocationChanged() {\n this._isUntransformedHitBoxesDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n updateHitBoxes(): void {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n\n // Update the current hitboxes with the frame custom hit boxes\n // and apply transformations.\n const localTransformation = this.getLocalTransformation();\n for (let i = 0; i < this._untransformedHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < this._untransformedHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n localTransformation.transform(\n this._untransformedHitBoxes[i].vertices[j],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length = this._untransformedHitBoxes[\n i\n ].vertices.length;\n }\n }\n\n /**\n * Merge the hitboxes of the children.\n */\n _updateUntransformedHitBoxes() {\n this._isUntransformedHitBoxesDirty = false;\n\n this._untransformedHitBoxes.length = 0;\n let minX = Number.MAX_VALUE;\n let minY = Number.MAX_VALUE;\n let maxX = -Number.MAX_VALUE;\n let maxY = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n Array.prototype.push.apply(\n this._untransformedHitBoxes,\n childInstance.getHitBoxes()\n );\n const childAABB = childInstance.getAABB();\n minX = Math.min(minX, childAABB.min[0]);\n minY = Math.min(minY, childAABB.min[1]);\n maxX = Math.max(maxX, childAABB.max[0]);\n maxY = Math.max(maxY, childAABB.max[1]);\n }\n if (minX === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minX = 0;\n minY = 0;\n maxX = 1;\n maxY = 1;\n }\n this._unrotatedAABB.min[0] = minX;\n this._unrotatedAABB.min[1] = minY;\n this._unrotatedAABB.max[0] = maxX;\n this._unrotatedAABB.max[1] = maxY;\n\n while (this.hitBoxes.length < this._untransformedHitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n this.hitBoxes.length = this._untransformedHitBoxes.length;\n }\n\n // Position:\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in parent coordinate coordinates (as opposed to the object local coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in parent coordinates).\n */\n applyObjectTransformation(x: float, y: float, destination: FloatPoint) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalTransformation().transform(source, destination);\n }\n\n /**\n * Return the affine transformation that represents\n * flipping, scale, rotation and translation of the object.\n * @returns the affine transformation.\n */\n getLocalTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localTransformation;\n }\n\n getLocalInverseTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localInverseTransformation;\n }\n\n _updateLocalTransformation() {\n const absScaleX = Math.abs(this._scaleX);\n const absScaleY = Math.abs(this._scaleY);\n const centerX = this.getUnscaledCenterX() * absScaleX;\n const centerY = this.getUnscaledCenterY() * absScaleY;\n const angleInRadians = (this.angle * Math.PI) / 180;\n\n this._localTransformation.setToTranslation(this.x, this.y);\n this._localTransformation.rotateAround(angleInRadians, centerX, centerY);\n if (this._flippedX) {\n this._localTransformation.flipX(centerX);\n }\n if (this._flippedY) {\n this._localTransformation.flipY(centerY);\n }\n this._localTransformation.scale(absScaleX, absScaleY);\n\n this._localInverseTransformation.copyFrom(this._localTransformation);\n this._localInverseTransformation.invert();\n this._isLocalTransformationDirty = false;\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in object local coordinates (as opposed to the parent coordinate coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in parent coordinates.\n * @param y The Y position of the point, in parent coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in object coordinates).\n */\n applyObjectInverseTransformation(\n x: float,\n y: float,\n destination: FloatPoint\n ) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalInverseTransformation().transform(source, destination);\n }\n\n getDrawableX(): float {\n let minX = 0;\n if (this._forcedDefaultSize) {\n minX = this._forcedDefaultSize.min[0];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minX = this._unrotatedAABB.min[0];\n }\n const absScaleX = this.getScaleX();\n if (!this._flippedX) {\n return this.x + minX * absScaleX;\n } else {\n return (\n this.x +\n (-minX - this.getUnscaledWidth() + 2 * this.getUnscaledCenterX()) *\n absScaleX\n );\n }\n }\n\n getDrawableY(): float {\n let minY = 0;\n if (this._forcedDefaultSize) {\n minY = this._forcedDefaultSize.min[1];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minY = this._unrotatedAABB.min[1];\n }\n const absScaleY = this.getScaleY();\n if (!this._flippedY) {\n return this.y + minY * absScaleY;\n } else {\n return (\n this.y +\n (-minY - this.getUnscaledHeight() + 2 * this.getUnscaledCenterY()) *\n absScaleY\n );\n }\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledWidth(): float {\n if (this._forcedDefaultSize) {\n return this._forcedDefaultSize.max[0] - this._forcedDefaultSize.min[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[0] - this._unrotatedAABB.min[0];\n }\n\n /**\n * @return the internal height of the object according to its children.\n */\n getUnscaledHeight(): float {\n if (this._forcedDefaultSize) {\n return this._forcedDefaultSize.max[1] - this._forcedDefaultSize.min[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[1] - this._unrotatedAABB.min[1];\n }\n\n /**\n * @returns the center X from the local origin (0;0).\n */\n getUnscaledCenterX(): float {\n if (this._customCenter) {\n return this._customCenter[0];\n }\n if (this._forcedDefaultSize) {\n return (\n (this._forcedDefaultSize.min[0] + this._forcedDefaultSize.max[0]) / 2\n );\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[0] + this._unrotatedAABB.max[0]) / 2;\n }\n\n /**\n * @returns the center Y from the local origin (0;0).\n */\n getUnscaledCenterY(): float {\n if (this._customCenter) {\n return this._customCenter[1];\n }\n if (this._forcedDefaultSize) {\n return (\n (this._forcedDefaultSize.min[1] + this._forcedDefaultSize.max[1]) / 2\n );\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[1] + this._unrotatedAABB.max[1]) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter(x: float, y: float) {\n if (!this._customCenter) {\n this._customCenter = [0, 0];\n }\n this._customCenter[0] = x;\n this._customCenter[1] = y;\n\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n }\n\n hasCustomRotationCenter(): boolean {\n return !!this._customCenter;\n }\n\n getCenterX(): float {\n return (\n (this.getUnscaledCenterX() - this._unrotatedAABB.min[0]) *\n this.getScaleX()\n );\n }\n\n getCenterY(): float {\n return (\n (this.getUnscaledCenterY() - this._unrotatedAABB.min[1]) *\n this.getScaleY()\n );\n }\n\n getWidth(): float {\n return this.getUnscaledWidth() * this.getScaleX();\n }\n\n getHeight(): float {\n return this.getUnscaledHeight() * this.getScaleY();\n }\n\n setWidth(newWidth: float): void {\n const unscaledWidth = this.getUnscaledWidth();\n if (unscaledWidth !== 0) {\n this.setScaleX(newWidth / unscaledWidth);\n }\n }\n\n setHeight(newHeight: float): void {\n const unscaledHeight = this.getUnscaledHeight();\n if (unscaledHeight !== 0) {\n this.setScaleY(newHeight / unscaledHeight);\n }\n }\n\n /**\n * Change the size of the object.\n *\n * @param newWidth The new width of the object, in pixels.\n * @param newHeight The new height of the object, in pixels.\n */\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateX();\n }\n\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateY();\n }\n\n setAngle(angle: float): void {\n if (this.angle === angle) {\n return;\n }\n this.angle = angle;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateAngle();\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n // Visibility and display :\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this.getRenderer().updateOpacity();\n }\n\n getOpacity(): number {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this.getRenderer().updateVisibility();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n /**\n * Return the sprite animator.\n *\n * It returns `null` when custom objects don't have the Animatable capability.\n */\n getAnimator(): gdjs.SpriteAnimator<any> | null {\n return null;\n }\n }\n\n // Others initialization and internal state management :\n // TODO EBO Activate and test instance recycling.\n CustomRuntimeObject.supportsReinitialization = false;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('CustomRuntimeObject');\n\n export type ObjectConfiguration = {\n content: any;\n };\n\n export type CustomObjectConfiguration = ObjectConfiguration & {\n animatable?: SpriteAnimationData[];\n childrenContent: { [objectName: string]: ObjectConfiguration & any };\n };\n\n /**\n * An object that contains other object.\n *\n * This is the base class for objects generated from EventsBasedObject.\n *\n * @see gdjs.CustomRuntimeObjectInstanceContainer\n */\n export abstract class CustomRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.OpacityHandler {\n _renderer:\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n /** It contains the children of this object. */\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _isUntransformedHitBoxesDirty: boolean = true;\n /** It contains shallow copies of the children hitboxes */\n private _untransformedHitBoxes: gdjs.Polygon[] = [];\n /** The dimension of this object is calculated from its children AABBs. */\n private _unrotatedAABB: AABB = { min: [0, 0], max: [0, 0] };\n /**\n * The bounds of the object content before any transformation.\n * @see gdjs.CustomRuntimeObjectInstanceContainer._initialInnerArea\n **/\n protected _innerArea: {\n min: [float, float, float];\n max: [float, float, float];\n } | null = null;\n /**\n * When the parent dimensions change:\n * - if `false`, the object is stretch proportionally while children local\n * positions stay the same ({@link gdjs.CustomRuntimeObject._innerArea} don't change).\n * - if `true`, the children local positions need to be adapted by events\n * to follow their parent size.\n */\n protected _isInnerAreaFollowingParentSize = false;\n private _scaleX: float = 1;\n private _scaleY: float = 1;\n private _flippedX: boolean = false;\n private _flippedY: boolean = false;\n private opacity: float = 255;\n private _customCenter: FloatPoint | null = null;\n private _localTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n private _localInverseTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n private _isLocalTransformationDirty: boolean = true;\n _type: string;\n\n /**\n * @param parent The container the object belongs to\n * @param objectData The object data used to initialize the object\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: ObjectData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._type = objectData.type;\n this._instanceContainer = new gdjs.CustomRuntimeObjectInstanceContainer(\n parent,\n this\n );\n this._renderer = this._createRender();\n\n this._initializeFromObjectData(objectData);\n\n // The generated code calls onCreated at the constructor end\n // and onCreated calls its super implementation at its end.\n }\n\n private _initializeFromObjectData(\n objectData: ObjectData & CustomObjectConfiguration\n ) {\n const eventsBasedObjectData = this._runtimeScene\n .getGame()\n .getEventsBasedObjectData(objectData.type);\n if (!eventsBasedObjectData) {\n logger.error(\n `A CustomRuntimeObject was initialized (or re-initialized) from object data referring to an non existing events based object data with type \"${objectData.type}\".`\n );\n return;\n }\n this._isInnerAreaFollowingParentSize =\n eventsBasedObjectData.isInnerAreaFollowingParentSize;\n if (eventsBasedObjectData.instances.length > 0) {\n if (!this._innerArea) {\n this._innerArea = {\n min: [0, 0, 0],\n max: [0, 0, 0],\n };\n }\n this._innerArea.min[0] = eventsBasedObjectData.areaMinX;\n this._innerArea.min[1] = eventsBasedObjectData.areaMinY;\n this._innerArea.min[2] = eventsBasedObjectData.areaMinZ;\n this._innerArea.max[0] = eventsBasedObjectData.areaMaxX;\n this._innerArea.max[1] = eventsBasedObjectData.areaMaxY;\n this._innerArea.max[2] = eventsBasedObjectData.areaMaxZ;\n }\n this._instanceContainer.loadFrom(objectData, eventsBasedObjectData);\n }\n\n protected abstract _createRender():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n protected abstract _reinitializeRenderer(): void;\n\n reinitialize(objectData: ObjectData & CustomObjectConfiguration) {\n super.reinitialize(objectData);\n\n this._initializeFromObjectData(objectData);\n this._reinitializeRenderer();\n\n // The generated code calls the onCreated super implementation at the end.\n this.onCreated();\n }\n\n updateFromObjectData(\n oldObjectData: ObjectData & CustomObjectConfiguration,\n newObjectData: ObjectData & CustomObjectConfiguration\n ): boolean {\n const animator = this.getAnimator();\n if (animator) {\n animator.updateFromObjectData(\n oldObjectData.animatable || [],\n newObjectData.animatable || []\n );\n }\n return true;\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n const animator = this.getAnimator();\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (animator && extraData.name === 'animation') {\n animator.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n onDeletedFromScene(parent: gdjs.RuntimeInstanceContainer): void {\n // Let subclasses do something before the object is destroyed.\n this.onDestroy(parent);\n // Let behaviors do something before the object is destroyed.\n super.onDeletedFromScene(parent);\n // Destroy the children.\n this._instanceContainer.onDestroyFromScene(parent);\n }\n\n update(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreEvents();\n\n this.doStepPreEvents(this._instanceContainer);\n\n const profiler = this.getRuntimeScene().getProfiler();\n if (profiler) {\n profiler.begin(this.type);\n }\n // This is a bit like the \"scene\" events for custom objects.\n this.doStepPostEvents(this._instanceContainer);\n if (profiler) {\n profiler.end(this.type);\n }\n\n this._instanceContainer._updateObjectsPostEvents();\n }\n\n /**\n * This method is called when the preview is being hot-reloaded.\n */\n onHotReloading(parent: gdjs.RuntimeInstanceContainer) {}\n\n // This is only to handle trigger once.\n doStepPreEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called each tick after events are done.\n * @param parent The instanceContainer owning the object\n */\n doStepPostEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called when the object is being removed from its parent\n * container and is about to be destroyed/reused later.\n */\n onDestroy(parent: gdjs.RuntimeInstanceContainer) {}\n\n updatePreRender(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreRender();\n this.getRenderer().ensureUpToDate();\n }\n\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._renderer;\n }\n\n getChildrenContainer(): gdjs.RuntimeInstanceContainer {\n return this._instanceContainer;\n }\n\n onChildrenLocationChanged() {\n this._isUntransformedHitBoxesDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n updateHitBoxes(): void {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n\n // Update the current hitboxes with the frame custom hit boxes\n // and apply transformations.\n const localTransformation = this.getLocalTransformation();\n for (let i = 0; i < this._untransformedHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < this._untransformedHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n localTransformation.transform(\n this._untransformedHitBoxes[i].vertices[j],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length = this._untransformedHitBoxes[\n i\n ].vertices.length;\n }\n }\n\n /**\n * Merge the hitboxes of the children.\n */\n _updateUntransformedHitBoxes() {\n this._isUntransformedHitBoxesDirty = false;\n\n this._untransformedHitBoxes.length = 0;\n let minX = Number.MAX_VALUE;\n let minY = Number.MAX_VALUE;\n let maxX = -Number.MAX_VALUE;\n let maxY = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n Array.prototype.push.apply(\n this._untransformedHitBoxes,\n childInstance.getHitBoxes()\n );\n const childAABB = childInstance.getAABB();\n minX = Math.min(minX, childAABB.min[0]);\n minY = Math.min(minY, childAABB.min[1]);\n maxX = Math.max(maxX, childAABB.max[0]);\n maxY = Math.max(maxY, childAABB.max[1]);\n }\n if (minX === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minX = 0;\n minY = 0;\n maxX = 1;\n maxY = 1;\n }\n this._unrotatedAABB.min[0] = minX;\n this._unrotatedAABB.min[1] = minY;\n this._unrotatedAABB.max[0] = maxX;\n this._unrotatedAABB.max[1] = maxY;\n\n while (this.hitBoxes.length < this._untransformedHitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n this.hitBoxes.length = this._untransformedHitBoxes.length;\n }\n\n // Position:\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in parent coordinate coordinates (as opposed to the object local coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in parent coordinates).\n */\n applyObjectTransformation(x: float, y: float, destination: FloatPoint) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalTransformation().transform(source, destination);\n }\n\n /**\n * Return the affine transformation that represents\n * flipping, scale, rotation and translation of the object.\n * @returns the affine transformation.\n */\n getLocalTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localTransformation;\n }\n\n getLocalInverseTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localInverseTransformation;\n }\n\n _updateLocalTransformation() {\n const absScaleX = Math.abs(this._scaleX);\n const absScaleY = Math.abs(this._scaleY);\n const centerX = this.getUnscaledCenterX() * absScaleX;\n const centerY = this.getUnscaledCenterY() * absScaleY;\n const angleInRadians = (this.angle * Math.PI) / 180;\n\n this._localTransformation.setToTranslation(this.x, this.y);\n this._localTransformation.rotateAround(angleInRadians, centerX, centerY);\n if (this._flippedX) {\n this._localTransformation.flipX(centerX);\n }\n if (this._flippedY) {\n this._localTransformation.flipY(centerY);\n }\n this._localTransformation.scale(absScaleX, absScaleY);\n\n this._localInverseTransformation.copyFrom(this._localTransformation);\n this._localInverseTransformation.invert();\n this._isLocalTransformationDirty = false;\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in object local coordinates (as opposed to the parent coordinate coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in parent coordinates.\n * @param y The Y position of the point, in parent coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in object coordinates).\n */\n applyObjectInverseTransformation(\n x: float,\n y: float,\n destination: FloatPoint\n ) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalInverseTransformation().transform(source, destination);\n }\n\n getDrawableX(): float {\n let minX = 0;\n if (this._innerArea) {\n minX = this._innerArea.min[0];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minX = this._unrotatedAABB.min[0];\n }\n const absScaleX = this.getScaleX();\n if (!this._flippedX) {\n return this.x + minX * absScaleX;\n } else {\n return (\n this.x +\n (-minX - this.getUnscaledWidth() + 2 * this.getUnscaledCenterX()) *\n absScaleX\n );\n }\n }\n\n getDrawableY(): float {\n let minY = 0;\n if (this._innerArea) {\n minY = this._innerArea.min[1];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minY = this._unrotatedAABB.min[1];\n }\n const absScaleY = this.getScaleY();\n if (!this._flippedY) {\n return this.y + minY * absScaleY;\n } else {\n return (\n this.y +\n (-minY - this.getUnscaledHeight() + 2 * this.getUnscaledCenterY()) *\n absScaleY\n );\n }\n }\n\n /**\n * @return the internal left bound of the object according to its children.\n */\n getInnerAreaMinX(): number {\n if (this._innerArea) {\n return this._innerArea.min[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.min[0];\n }\n\n /**\n * @return the internal top bound of the object according to its children.\n */\n getInnerAreaMinY(): number {\n if (this._innerArea) {\n return this._innerArea.min[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.min[1];\n }\n\n /**\n * @return the internal right bound of the object according to its children.\n */\n getInnerAreaMaxX(): number {\n if (this._innerArea) {\n return this._innerArea.max[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[0];\n }\n\n /**\n * @return the internal bottom bound of the object according to its children.\n */\n getInnerAreaMaxY(): number {\n if (this._innerArea) {\n return this._innerArea.max[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[1];\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledWidth(): float {\n if (this._innerArea) {\n return this._innerArea.max[0] - this._innerArea.min[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[0] - this._unrotatedAABB.min[0];\n }\n\n /**\n * @return the internal height of the object according to its children.\n */\n getUnscaledHeight(): float {\n if (this._innerArea) {\n return this._innerArea.max[1] - this._innerArea.min[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[1] - this._unrotatedAABB.min[1];\n }\n\n /**\n * @returns the center X from the local origin (0;0).\n */\n getUnscaledCenterX(): float {\n if (this._customCenter) {\n return this._customCenter[0];\n }\n if (this._innerArea) {\n return (this._innerArea.min[0] + this._innerArea.max[0]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[0] + this._unrotatedAABB.max[0]) / 2;\n }\n\n /**\n * @returns the center Y from the local origin (0;0).\n */\n getUnscaledCenterY(): float {\n if (this._customCenter) {\n return this._customCenter[1];\n }\n if (this._innerArea) {\n return (this._innerArea.min[1] + this._innerArea.max[1]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[1] + this._unrotatedAABB.max[1]) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter(x: float, y: float) {\n if (!this._customCenter) {\n this._customCenter = [0, 0];\n }\n this._customCenter[0] = x;\n this._customCenter[1] = y;\n\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n }\n\n hasCustomRotationCenter(): boolean {\n return !!this._customCenter;\n }\n\n getCenterX(): float {\n return (\n (this.getUnscaledCenterX() - this._unrotatedAABB.min[0]) *\n this.getScaleX()\n );\n }\n\n getCenterY(): float {\n return (\n (this.getUnscaledCenterY() - this._unrotatedAABB.min[1]) *\n this.getScaleY()\n );\n }\n\n getWidth(): float {\n return this.getUnscaledWidth() * this.getScaleX();\n }\n\n getHeight(): float {\n return this.getUnscaledHeight() * this.getScaleY();\n }\n\n setWidth(newWidth: float): void {\n const unscaledWidth = this.getUnscaledWidth();\n if (unscaledWidth === 0) {\n return;\n }\n const scaleX = newWidth / unscaledWidth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[0] *= scaleX;\n this._innerArea.max[0] *= scaleX;\n } else {\n this.setScaleX(scaleX);\n }\n }\n\n setHeight(newHeight: float): void {\n const unscaledHeight = this.getUnscaledHeight();\n if (unscaledHeight === 0) {\n return;\n }\n const scaleY = newHeight / unscaledHeight;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[1] *= scaleY;\n this._innerArea.max[1] *= scaleY;\n } else {\n this.setScaleY(scaleY);\n }\n }\n\n /**\n * Change the size of the object.\n *\n * @param newWidth The new width of the object, in pixels.\n * @param newHeight The new height of the object, in pixels.\n */\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateX();\n }\n\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateY();\n }\n\n setAngle(angle: float): void {\n if (this.angle === angle) {\n return;\n }\n this.angle = angle;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateAngle();\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n // Visibility and display :\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this.getRenderer().updateOpacity();\n }\n\n getOpacity(): number {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this.getRenderer().updateVisibility();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n /**\n * Return the sprite animator.\n *\n * It returns `null` when custom objects don't have the Animatable capability.\n */\n getAnimator(): gdjs.SpriteAnimator<any> | null {\n return null;\n }\n }\n\n // Others initialization and internal state management :\n // TODO EBO Activate and test instance recycling.\n CustomRuntimeObject.supportsReinitialization = false;\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,uBAkBxB,eACG,GAAK,aAKS,CA0CtB,YACE,EACA,EACA,CACA,MAAM,EAAQ,GAxChB,mCAAyC,GAEjC,4BAAyC,GAEzC,oBAAuB,CAAE,IAAK,CAAC,EAAG,GAAI,IAAK,CAAC,EAAG,IAK7C,gBA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Ac,WAQrB,UAAU,EAAuB,CAC/B,AAAI,KAAK,YAAc,KAAK,iCAIxB,GAAW,GACb,GAAW,GAET,IAAa,KAAK,IAAI,KAAK,UAG/B,MAAK,QAAU,EAAY,MAAK,UAAY,GAAK,GACjD,KAAK,qBACL,KAAK,cAAc,WASrB,cAAsB,CACpB,MAAQ,MAAK,IAAI,KAAK,SAAW,KAAK,IAAI,KAAK,UAAY,EAQ7D,UAAkB,CAChB,KAAM,GAAS,KAAK,IAAI,KAAK,SACvB,EAAS,KAAK,IAAI,KAAK,SAC7B,MAAO,KAAW,EAAS,EAAS,KAAK,KAAK,EAAS,GAQzD,WAAmB,CACjB,MAAO,MAAK,IAAI,KAAK,SAQvB,WAAmB,CACjB,MAAO,MAAK,IAAI,KAAK,SAKvB,WAAW,EAAsB,CAC/B,AAAI,EAAU,GACZ,GAAU,GAER,EAAU,KACZ,GAAU,KAEZ,KAAK,QAAU,EACf,KAAK,cAAc,gBAGrB,YAAqB,CACnB,MAAO,MAAK,QAOd,KAAK,EAAuB,CAC1B,AAAI,IAAW,QACb,GAAS,IAEX,KAAK,OAAS,EACd,KAAK,cAAc,mBAGrB,MAAM,EAAiB,CACrB,AAAI,IAAW,KAAK,WAClB,MAAK,SAAW,GAChB,KAAK,UAAY,EACjB,KAAK,qBACL,KAAK,cAAc,UAIvB,MAAM,EAAiB,CACrB,AAAI,IAAW,KAAK,WAClB,MAAK,SAAW,GAChB,KAAK,UAAY,EACjB,KAAK,qBACL,KAAK,cAAc,UAIvB,YAAsB,CACpB,MAAO,MAAK,UAGd,YAAsB,CACpB,MAAO,MAAK,UAQd,aAA+C,CAC7C,MAAO,OA3yBJ,EAAe,sBAizBtB,EAAoB,yBAA2B,KAp0BvC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(s){class l extends s.RuntimeInstanceContainer{constructor(t,n){super();this._isLoaded=!1;this._initialInnerArea=null;this._parent=t,this._customObject=n,this._runtimeScene=t.getScene(),this._debuggerRenderer=new s.DebuggerRenderer(this)}addLayer(t){const n=new s.RuntimeCustomObjectLayer(t,this);this._layers.put(t.name,n),this._orderedLayers.push(n)}createObject(t){const n=super.createObject(t);return this._customObject.onChildrenLocationChanged(),n}loadFrom(t,n){this._isLoaded&&this.onDestroyFromScene(this._parent),this._setOriginalInnerArea(n);for(let r=0,e=n.objects.length;r<e;++r){const i=n.objects[r];t.childrenContent?this.registerObject({...i,...t.childrenContent[i.name]}):this.registerObject(i)}if(n.layers.length>0)for(let r=0,e=n.layers.length;r<e;++r)this.addLayer(n.layers[r]);else this.addLayer({name:"",visibility:!0,cameras:[{defaultSize:!0,defaultViewport:!0,height:0,viewportBottom:0,viewportLeft:0,viewportRight:0,viewportTop:0,width:0}],effects:[],ambientLightColorR:0,ambientLightColorG:0,ambientLightColorB:0,isLightingLayer:!1,followBaseLayerCamera:!1});this.createObjectsFrom(n.instances,0,0,0,!0),this._setLayerDefaultZOrders(),this._isLoaded=!0}_setOriginalInnerArea(t){t.instances.length>0&&(t._initialInnerArea||(t._initialInnerArea={min:[t.areaMinX,t.areaMinY,t.areaMinZ],max:[t.areaMaxX,t.areaMaxY,t.areaMaxZ]}),this._initialInnerArea=t._initialInnerArea)}onDestroyFromScene(t){if(!this._isLoaded)return;const n=this.getAdhocListOfAllInstances();for(let r=0,e=n.length;r<e;++r){const i=n[r];i.onDeletedFromScene(this),i.onDestroyed()}this._destroy(),this._isLoaded=!1}_destroy(){super._destroy(),this._onceTriggers=null}_updateObjectsPreRender(){const t=this.getAdhocListOfAllInstances();for(let n=0,r=t.length;n<r;++n){const e=t[n],i=e.getRendererObject();i&&(i.visible=!e.isHidden(),i.visible&&this.getGame().getEffectsManager().updatePreRender(e.getRendererEffects(),e)),this._debugDrawEnabled&&this._debuggerRenderer.renderDebugDraw(t,this._debugDrawShowHiddenInstances,this._debugDrawShowPointsNames,this._debugDrawShowCustomPoints),e.updatePreRender(this)}}_updateObjectsPreEvents(){const t=this.getAdhocListOfAllInstances();for(let n=0,r=t.length;n<r;++n){const e=t[n],i=e.getElapsedTime();if(e.hasNoForces())e.update(this);else{const a=e.getAverageForce(),o=i/1e3;e.setX(e.getX()+a.getX()*o),e.setY(e.getY()+a.getY()*o),e.update(this),e.updateForces(o)}e.updateTimers(i),e.stepBehaviorsPreEvents(this)}this._cacheOrClearRemovedInstances()}getRenderer(){return this._customObject.getRenderer()}getDebuggerRenderer(){return this._debuggerRenderer}getGame(){return this._runtimeScene.getGame()}getScene(){return this._runtimeScene}getUnrotatedViewportMinX(){return this._customObject.getInnerAreaMinX()}getUnrotatedViewportMinY(){return this._customObject.getInnerAreaMinY()}getUnrotatedViewportMaxX(){return this._customObject.getInnerAreaMaxX()}getUnrotatedViewportMaxY(){return this._customObject.getInnerAreaMaxY()}getInitialUnrotatedViewportMinX(){return this._initialInnerArea?this._initialInnerArea.min[0]:0}getInitialUnrotatedViewportMinY(){return this._initialInnerArea?this._initialInnerArea.min[1]:0}getInitialUnrotatedViewportMaxX(){return this._initialInnerArea?this._initialInnerArea.max[0]:0}getInitialUnrotatedViewportMaxY(){return this._initialInnerArea?this._initialInnerArea.max[1]:0}getViewportWidth(){return this._customObject.getUnscaledWidth()}getViewportHeight(){return this._customObject.getUnscaledHeight()}getViewportOriginX(){return this._customObject.getUnscaledCenterX()}getViewportOriginY(){return this._customObject.getUnscaledCenterY()}onChildrenLocationChanged(){this._customObject.onChildrenLocationChanged()}convertCoords(t,n,r){let e=r||[0,0];return e=this._parent.getLayer(this._customObject.getLayer()).convertCoords(t,n,0,e),this._customObject.applyObjectInverseTransformation(e[0],e[1],e),e}convertInverseCoords(t,n,r){const e=r||[0,0];return this._customObject.applyObjectTransformation(t,n,e),this._parent.convertInverseCoords(e[0],e[1],e)}getElapsedTime(){return this._parent.getElapsedTime()}}s.CustomRuntimeObjectInstanceContainer=l})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=CustomRuntimeObjectInstanceContainer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/CustomRuntimeObjectInstanceContainer.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('CustomRuntimeObject');\n\n /**\n * The instance container of a custom object, containing instances of objects rendered on screen.\n *\n * @see gdjs.CustomRuntimeObject\n */\n export class CustomRuntimeObjectInstanceContainer extends gdjs.RuntimeInstanceContainer {\n _debuggerRenderer: gdjs.DebuggerRenderer;\n _runtimeScene: gdjs.RuntimeScene;\n /** The parent container that contains the object associated with this container. */\n _parent: gdjs.RuntimeInstanceContainer;\n /** The object that is built with the instances of this container. */\n _customObject: gdjs.CustomRuntimeObject;\n _isLoaded: boolean = false;\n\n /**\n * @param parent the parent container that contains the object associated\n * with this container.\n * @param customObject the object that is built with the instances of this\n * container.\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n customObject: gdjs.CustomRuntimeObject\n ) {\n super();\n this._parent = parent;\n this._customObject = customObject;\n this._runtimeScene = parent.getScene();\n this._debuggerRenderer = new gdjs.DebuggerRenderer(this);\n }\n\n addLayer(layerData: LayerData) {\n const layer = new gdjs.RuntimeCustomObjectLayer(layerData, this);\n this._layers.put(layerData.name, layer);\n this._orderedLayers.push(layer);\n }\n\n createObject(objectName: string): gdjs.RuntimeObject | null {\n const result = super.createObject(objectName);\n this._customObject.onChildrenLocationChanged();\n return result;\n }\n\n /**\n * Load the container from the given initial configuration.\n * @param customObjectData An object containing the container data.\n * @see gdjs.RuntimeGame#getSceneAndExtensionsData\n */\n loadFrom(customObjectData: ObjectData & CustomObjectConfiguration) {\n if (this._isLoaded) {\n this.onDestroyFromScene(this._parent);\n }\n\n const eventsBasedObjectData = this._runtimeScene\n .getGame()\n .getEventsBasedObjectData(customObjectData.type);\n if (!eventsBasedObjectData) {\n logger.error('loadFrom was called without an events-based object');\n return;\n }\n\n // Registering objects\n for (\n let i = 0, len = eventsBasedObjectData.objects.length;\n i < len;\n ++i\n ) {\n const childObjectData = eventsBasedObjectData.objects[i];\n this.registerObject({\n ...childObjectData,\n ...customObjectData.childrenContent[childObjectData.name],\n });\n }\n\n if (customObjectData.layers.length > 0) {\n // Load layers\n for (let i = 0, len = customObjectData.layers.length; i < len; ++i) {\n this.addLayer(customObjectData.layers[i]);\n }\n } else {\n // Add a default layer\n this.addLayer({\n name: '',\n visibility: true,\n cameras: [\n {\n defaultSize: true,\n defaultViewport: true,\n height: 0,\n viewportBottom: 0,\n viewportLeft: 0,\n viewportRight: 0,\n viewportTop: 0,\n width: 0,\n },\n ],\n effects: [],\n ambientLightColorR: 0,\n ambientLightColorG: 0,\n ambientLightColorB: 0,\n isLightingLayer: false,\n followBaseLayerCamera: false,\n });\n }\n\n this.createObjectsFrom(\n customObjectData.instances,\n 0,\n 0,\n 0,\n // TODO EBO: handle hot-reloading for custom objects (including nested custom objects)\n true\n );\n\n // Set up the default z order (for objects created from events)\n this._setLayerDefaultZOrders();\n\n this._isLoaded = true;\n }\n\n /**\n * Called when the container must be updated using the specified\n * objectData. This is the case during hot-reload, and is only called if\n * the object was modified.\n *\n * @param oldCustomObjectData The previous data for the object.\n * @param newCustomObjectData The new data for the object.\n * @returns true if the object was updated, false if it could not\n * (i.e: hot-reload is not supported).\n */\n updateFrom(\n oldCustomObjectData: ObjectData & CustomObjectConfiguration,\n newCustomObjectData: ObjectData & CustomObjectConfiguration\n ): boolean {\n const eventsBasedObjectData = this._runtimeScene\n .getGame()\n .getEventsBasedObjectData(newCustomObjectData.type);\n if (!eventsBasedObjectData) {\n logger.error('updateFrom was called without an events-based object');\n return false;\n }\n\n for (\n let i = 0, len = eventsBasedObjectData.objects.length;\n i < len;\n ++i\n ) {\n const childName = eventsBasedObjectData.objects[i].name;\n const oldChildData = {\n ...eventsBasedObjectData.objects[i],\n ...oldCustomObjectData.childrenContent[childName],\n };\n const newChildData = {\n ...eventsBasedObjectData.objects[i],\n ...newCustomObjectData.childrenContent[childName],\n };\n this.updateObject(newChildData);\n\n for (const child of this.getInstancesOf(childName)) {\n child.updateFromObjectData(oldChildData, newChildData);\n }\n }\n return true;\n }\n\n /**\n * Called when the associated object is destroyed (because it is removed\n * from its parent container or the scene is being unloaded).\n *\n * @param instanceContainer The container owning the object.\n */\n onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (!this._isLoaded) {\n return;\n }\n\n // Notify the objects they are being destroyed\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onDeletedFromScene(this);\n }\n\n this._destroy();\n\n this._isLoaded = false;\n }\n\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n super._destroy();\n // @ts-ignore We are deleting the object\n this._onceTriggers = null;\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Set to true to enable debug rendering (look for the implementation in the renderer\n // to see what is rendered).\n if (this._debugDrawEnabled) {\n this._debuggerRenderer.renderDebugDraw(\n allInstancesList,\n this._debugDrawShowHiddenInstances,\n this._debugDrawShowPointsNames,\n this._debugDrawShowCustomPoints\n );\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n obj.stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Get the renderer associated to the RuntimeScene.\n */\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._customObject.getRenderer();\n }\n\n getDebuggerRenderer() {\n return this._debuggerRenderer;\n }\n\n getGame() {\n return this._runtimeScene.getGame();\n }\n\n getScene() {\n return this._runtimeScene;\n }\n\n getViewportWidth(): float {\n return this._customObject.getUnscaledWidth();\n }\n\n getViewportHeight(): float {\n return this._customObject.getUnscaledHeight();\n }\n\n getViewportOriginX(): float {\n return this._customObject.getUnscaledCenterX();\n }\n\n getViewportOriginY(): float {\n return this._customObject.getUnscaledCenterY();\n }\n\n onChildrenLocationChanged(): void {\n this._customObject.onChildrenLocationChanged();\n }\n\n convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {\n // The result parameter used to be optional.\n let position = result || [0, 0];\n position = this._parent\n .getLayer(this._customObject.getLayer())\n .convertCoords(x, y, 0, position);\n this._customObject.applyObjectInverseTransformation(\n position[0],\n position[1],\n position\n );\n return position;\n }\n\n convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint {\n const position = result || [0, 0];\n this._customObject.applyObjectTransformation(sceneX, sceneY, position);\n return this._parent.convertInverseCoords(\n position[0],\n position[1],\n position\n );\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n getElapsedTime(): float {\n return this._parent.getElapsedTime();\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * The instance container of a custom object, containing instances of objects rendered on screen.\n *\n * @see gdjs.CustomRuntimeObject\n */\n export class CustomRuntimeObjectInstanceContainer extends gdjs.RuntimeInstanceContainer {\n _debuggerRenderer: gdjs.DebuggerRenderer;\n _runtimeScene: gdjs.RuntimeScene;\n /** The parent container that contains the object associated with this container. */\n _parent: gdjs.RuntimeInstanceContainer;\n /** The object that is built with the instances of this container. */\n _customObject: gdjs.CustomRuntimeObject;\n _isLoaded: boolean = false;\n /**\n * The default size defined by users in the custom object initial instances editor.\n *\n * Don't modify it as it would affect every instance.\n *\n * @see gdjs.CustomRuntimeObject._innerArea\n **/\n private _initialInnerArea: {\n min: [float, float, float];\n max: [float, float, float];\n } | null = null;\n\n /**\n * @param parent the parent container that contains the object associated\n * with this container.\n * @param customObject the object that is built with the instances of this\n * container.\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n customObject: gdjs.CustomRuntimeObject\n ) {\n super();\n this._parent = parent;\n this._customObject = customObject;\n this._runtimeScene = parent.getScene();\n this._debuggerRenderer = new gdjs.DebuggerRenderer(this);\n }\n\n addLayer(layerData: LayerData) {\n const layer = new gdjs.RuntimeCustomObjectLayer(layerData, this);\n this._layers.put(layerData.name, layer);\n this._orderedLayers.push(layer);\n }\n\n createObject(objectName: string): gdjs.RuntimeObject | null {\n const result = super.createObject(objectName);\n this._customObject.onChildrenLocationChanged();\n return result;\n }\n\n /**\n * Load the container from the given initial configuration.\n * @param customObjectData An object containing the container data.\n * @see gdjs.RuntimeGame#getSceneAndExtensionsData\n */\n loadFrom(\n customObjectData: ObjectData & CustomObjectConfiguration,\n eventsBasedObjectData: EventsBasedObjectData\n ) {\n if (this._isLoaded) {\n this.onDestroyFromScene(this._parent);\n }\n\n this._setOriginalInnerArea(eventsBasedObjectData);\n\n // Registering objects\n for (\n let i = 0, len = eventsBasedObjectData.objects.length;\n i < len;\n ++i\n ) {\n const childObjectData = eventsBasedObjectData.objects[i];\n if (customObjectData.childrenContent) {\n this.registerObject({\n ...childObjectData,\n // The custom object overrides its events-based object configuration.\n ...customObjectData.childrenContent[childObjectData.name],\n });\n } else {\n // The custom object follows its events-based object configuration.\n this.registerObject(childObjectData);\n }\n }\n\n if (eventsBasedObjectData.layers.length > 0) {\n // Load layers\n for (\n let i = 0, len = eventsBasedObjectData.layers.length;\n i < len;\n ++i\n ) {\n this.addLayer(eventsBasedObjectData.layers[i]);\n }\n } else {\n // Add a default layer\n this.addLayer({\n name: '',\n visibility: true,\n cameras: [\n {\n defaultSize: true,\n defaultViewport: true,\n height: 0,\n viewportBottom: 0,\n viewportLeft: 0,\n viewportRight: 0,\n viewportTop: 0,\n width: 0,\n },\n ],\n effects: [],\n ambientLightColorR: 0,\n ambientLightColorG: 0,\n ambientLightColorB: 0,\n isLightingLayer: false,\n followBaseLayerCamera: false,\n });\n }\n\n this.createObjectsFrom(\n eventsBasedObjectData.instances,\n 0,\n 0,\n 0,\n // TODO EBO: handle hot-reloading for custom objects (including nested custom objects)\n true\n );\n\n // Set up the default z order (for objects created from events)\n this._setLayerDefaultZOrders();\n\n this._isLoaded = true;\n }\n\n /**\n * Initialize `_initialInnerArea` if it doesn't exist.\n * `_initialInnerArea` is shared by every instance to save memory.\n */\n private _setOriginalInnerArea(\n eventsBasedObjectData: EventsBasedObjectData\n ) {\n if (eventsBasedObjectData.instances.length > 0) {\n if (!eventsBasedObjectData._initialInnerArea) {\n eventsBasedObjectData._initialInnerArea = {\n min: [\n eventsBasedObjectData.areaMinX,\n eventsBasedObjectData.areaMinY,\n eventsBasedObjectData.areaMinZ,\n ],\n max: [\n eventsBasedObjectData.areaMaxX,\n eventsBasedObjectData.areaMaxY,\n eventsBasedObjectData.areaMaxZ,\n ],\n };\n }\n this._initialInnerArea = eventsBasedObjectData._initialInnerArea;\n }\n }\n\n /**\n * Called when the associated object is destroyed (because it is removed\n * from its parent container or the scene is being unloaded).\n *\n * @param instanceContainer The container owning the object.\n */\n onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (!this._isLoaded) {\n return;\n }\n\n // Notify the objects they are being destroyed\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onDeletedFromScene(this);\n // The object can free all its resource directly...\n object.onDestroyed();\n }\n // ...as its container cache `_instancesRemoved` is also destroy.\n this._destroy();\n\n this._isLoaded = false;\n }\n\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n super._destroy();\n // @ts-ignore We are deleting the object\n this._onceTriggers = null;\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Set to true to enable debug rendering (look for the implementation in the renderer\n // to see what is rendered).\n if (this._debugDrawEnabled) {\n this._debuggerRenderer.renderDebugDraw(\n allInstancesList,\n this._debugDrawShowHiddenInstances,\n this._debugDrawShowPointsNames,\n this._debugDrawShowCustomPoints\n );\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n obj.stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Get the renderer associated to the RuntimeScene.\n */\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._customObject.getRenderer();\n }\n\n getDebuggerRenderer() {\n return this._debuggerRenderer;\n }\n\n getGame() {\n return this._runtimeScene.getGame();\n }\n\n getScene() {\n return this._runtimeScene;\n }\n\n getUnrotatedViewportMinX(): float {\n return this._customObject.getInnerAreaMinX();\n }\n\n getUnrotatedViewportMinY(): float {\n return this._customObject.getInnerAreaMinY();\n }\n\n getUnrotatedViewportMaxX(): float {\n return this._customObject.getInnerAreaMaxX();\n }\n\n getUnrotatedViewportMaxY(): float {\n return this._customObject.getInnerAreaMaxY();\n }\n\n getInitialUnrotatedViewportMinX(): float {\n return this._initialInnerArea ? this._initialInnerArea.min[0] : 0;\n }\n\n getInitialUnrotatedViewportMinY(): float {\n return this._initialInnerArea ? this._initialInnerArea.min[1] : 0;\n }\n\n getInitialUnrotatedViewportMaxX(): float {\n return this._initialInnerArea ? this._initialInnerArea.max[0] : 0;\n }\n\n getInitialUnrotatedViewportMaxY(): float {\n return this._initialInnerArea ? this._initialInnerArea.max[1] : 0;\n }\n\n getViewportWidth(): float {\n return this._customObject.getUnscaledWidth();\n }\n\n getViewportHeight(): float {\n return this._customObject.getUnscaledHeight();\n }\n\n getViewportOriginX(): float {\n return this._customObject.getUnscaledCenterX();\n }\n\n getViewportOriginY(): float {\n return this._customObject.getUnscaledCenterY();\n }\n\n onChildrenLocationChanged(): void {\n this._customObject.onChildrenLocationChanged();\n }\n\n convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {\n // The result parameter used to be optional.\n let position = result || [0, 0];\n position = this._parent\n .getLayer(this._customObject.getLayer())\n .convertCoords(x, y, 0, position);\n this._customObject.applyObjectInverseTransformation(\n position[0],\n position[1],\n position\n );\n return position;\n }\n\n convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint {\n const position = result || [0, 0];\n this._customObject.applyObjectTransformation(sceneX, sceneY, position);\n return this._parent.convertInverseCoords(\n position[0],\n position[1],\n position\n );\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n getElapsedTime(): float {\n return this._parent.getElapsedTime();\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAMS,eAAmD,GAAK,wBAAyB,CA0BtF,YACE,EACA,EACA,CACA,QAvBF,eAAqB,GAQb,uBAGG,KAaT,KAAK,QAAU,EACf,KAAK,cAAgB,EACrB,KAAK,cAAgB,EAAO,WAC5B,KAAK,kBAAoB,GAAI,GAAK,iBAAiB,MAGrD,SAAS,EAAsB,CAC7B,KAAM,GAAQ,GAAI,GAAK,yBAAyB,EAAW,MAC3D,KAAK,QAAQ,IAAI,EAAU,KAAM,GACjC,KAAK,eAAe,KAAK,GAG3B,a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AO,MAAK,kBAAoB,KAAK,kBAAkB,IAAI,GAAK,EAGlE,iCAAyC,CACvC,MAAO,MAAK,kBAAoB,KAAK,kBAAkB,IAAI,GAAK,EAGlE,iCAAyC,CACvC,MAAO,MAAK,kBAAoB,KAAK,kBAAkB,IAAI,GAAK,EAGlE,kBAA0B,CACxB,MAAO,MAAK,cAAc,mBAG5B,mBAA2B,CACzB,MAAO,MAAK,cAAc,oBAG5B,oBAA4B,CAC1B,MAAO,MAAK,cAAc,qBAG5B,oBAA4B,CAC1B,MAAO,MAAK,cAAc,qBAG5B,2BAAkC,CAChC,KAAK,cAAc,4BAGrB,cAAc,EAAU,EAAU,EAAgC,CAEhE,GAAI,GAAW,GAAU,CAAC,EAAG,GAC7B,SAAW,KAAK,QACb,SAAS,KAAK,cAAc,YAC5B,cAAc,EAAG,EAAG,EAAG,GAC1B,KAAK,cAAc,iCACjB,EAAS,GACT,EAAS,GACT,GAEK,EAGT,qBACE,EACA,EACA,EACY,CACZ,KAAM,GAAW,GAAU,CAAC,EAAG,GAC/B,YAAK,cAAc,0BAA0B,EAAQ,EAAQ,GACtD,KAAK,QAAQ,qBAClB,EAAS,GACT,EAAS,GACT,GAQJ,gBAAwB,CACtB,MAAO,MAAK,QAAQ,kBA9WjB,EAAM,yCANL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(r){class n extends r.CustomRuntimeObject{constructor(t,i){super(t,i);this._z=0;this._minZ=0;this._maxZ=0;this._scaleZ=1;this._flippedZ=!1;this._rotationX=0;this._rotationY=0;this._customCenterZ=0;this._renderer.reinitialize(this,t)}_createRender(){const t=this._runtimeScene;return new r.CustomRuntimeObject3DRenderer(this,this._instanceContainer,t)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}get3DRendererObject(){return this.getRenderer().get3DRendererObject()}extraInitializationFromInitialInstance(t){super.extraInitializationFromInitialInstance(t),t.depth!==void 0&&this.setDepth(t.depth)}setZ(t){t!==this._z&&(this._z=t,this.getRenderer().updatePosition())}getZ(){return this._z}getDrawableZ(){return this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._z+this._minZ}getCenterZ(){return this.getDepth()/2}getCenterZInScene(){return this.getDrawableZ()+this.getCenterZ()}setCenterZInScene(t){this.setZ(t+this._z-(this.getDrawableZ()+this.getCenterZ()))}getUnrotatedAABBMinZ(){return this.getDrawableZ()}getUnrotatedAABBMaxZ(){return this.getDrawableZ()+this.getDepth()}setRotationX(t){this._rotationX=t,this.getRenderer().updateRotation()}setRotationY(t){this._rotationY=t,this.getRenderer().updateRotation()}getRotationX(){return this._rotationX}getRotationY(){return this._rotationY}turnAroundX(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(1,0,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundY(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,1,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundZ(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,0,1);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}getUnscaledDepth(){return this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ-this._minZ}_updateUntransformedHitBoxes(){super._updateUntransformedHitBoxes();let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(const e of this._instanceContainer.getAdhocListOfAllInstances())!e.isIncludedInParentCollisionMask()||!r.Base3DHandler.is3D(e)||(t=Math.min(t,e.getUnrotatedAABBMinZ()),i=Math.max(i,e.getUnrotatedAABBMaxZ()));t===Number.MAX_VALUE&&(t=0,i=1),this._minZ=t,this._maxZ=i}getUnscaledCenterZ(){return this.hasCustomRotationCenter()?this._customCenterZ:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._minZ+this._maxZ)/2)}setRotationCenter3D(t,i,e){this._customCenterZ=e,this.setRotationCenter(t,i)}getDepth(){return this.getUnscaledDepth()*this.getScaleZ()}setDepth(t){const i=this.getUnscaledDepth();i
|
|
1
|
+
var gdjs;(function(r){class n extends r.CustomRuntimeObject{constructor(t,i){super(t,i);this._z=0;this._minZ=0;this._maxZ=0;this._scaleZ=1;this._flippedZ=!1;this._rotationX=0;this._rotationY=0;this._customCenterZ=0;this._renderer.reinitialize(this,t)}_createRender(){const t=this._runtimeScene;return new r.CustomRuntimeObject3DRenderer(this,this._instanceContainer,t)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}get3DRendererObject(){return this.getRenderer().get3DRendererObject()}extraInitializationFromInitialInstance(t){super.extraInitializationFromInitialInstance(t),t.depth!==void 0&&this.setDepth(t.depth)}setZ(t){t!==this._z&&(this._z=t,this.getRenderer().updatePosition())}getZ(){return this._z}getDrawableZ(){return this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._z+this._minZ}getCenterZ(){return this.getDepth()/2}getCenterZInScene(){return this.getDrawableZ()+this.getCenterZ()}setCenterZInScene(t){this.setZ(t+this._z-(this.getDrawableZ()+this.getCenterZ()))}getUnrotatedAABBMinZ(){return this.getDrawableZ()}getUnrotatedAABBMaxZ(){return this.getDrawableZ()+this.getDepth()}setRotationX(t){this._rotationX=t,this.getRenderer().updateRotation()}setRotationY(t){this._rotationY=t,this.getRenderer().updateRotation()}getRotationX(){return this._rotationX}getRotationY(){return this._rotationY}turnAroundX(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(1,0,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundY(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,1,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundZ(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,0,1);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}getUnscaledDepth(){return this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ-this._minZ}_updateUntransformedHitBoxes(){super._updateUntransformedHitBoxes();let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(const e of this._instanceContainer.getAdhocListOfAllInstances())!e.isIncludedInParentCollisionMask()||!r.Base3DHandler.is3D(e)||(t=Math.min(t,e.getUnrotatedAABBMinZ()),i=Math.max(i,e.getUnrotatedAABBMaxZ()));t===Number.MAX_VALUE&&(t=0,i=1),this._minZ=t,this._maxZ=i}getUnscaledCenterZ(){return this.hasCustomRotationCenter()?this._customCenterZ:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._minZ+this._maxZ)/2)}setRotationCenter3D(t,i,e){this._customCenterZ=e,this.setRotationCenter(t,i)}getDepth(){return this.getUnscaledDepth()*this.getScaleZ()}setDepth(t){const i=this.getUnscaledDepth();if(i===0)return;const e=t/i;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[2]*=e,this._innerArea.max[2]*=e):this.setScaleZ(e)}setScale(t){super.setScale(t),this.setScaleZ(t)}setScaleZ(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleZ)&&(this._scaleZ=t*(this._flippedZ?-1:1),this.getRenderer().updateSize()))}getScale(){const t=this.getScaleX(),i=this.getScaleY(),e=this.getScaleZ();return t===i&&t===e?t:Math.pow(t*i*e,1/3)}getScaleZ(){return Math.abs(this._scaleZ)}flipZ(t){t!==this._flippedZ&&(this._flippedZ=t,this.getRenderer().updateSize())}isFlippedZ(){return this._flippedZ}}n._temporaryVector=new THREE.Vector3,r.CustomRuntimeObject3D=n})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=CustomRuntimeObject3D.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/CustomRuntimeObject3D.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n export interface Object3DDataContent {\n width: float;\n height: float;\n depth: float;\n }\n /** Base parameters for {@link gdjs.RuntimeObject3D} */\n export interface Object3DData extends ObjectData {\n /** The base parameters of the RuntimeObject3D */\n content: Object3DDataContent;\n }\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: Object3DData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._renderer.reinitialize(this, parent);\n }\n\n protected _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined)\n this.setDepth(initialInstanceData.depth);\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._z + this._minZ;\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth !== 0) {\n this.setScaleZ(depth / unscaledDepth);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAeS,eACG,GAAK,mBACiB,CAwB9B,YACE,EACA,EACA,CACA,MAAM,EAAQ,GAxBR,QAAY,EACZ,WAAe,EACf,WAAe,EACf,aAAiB,EACjB,eAAqB,GAMrB,gBAAoB,EAMpB,gBAAoB,EACpB,oBAAwB,EAQ9B,KAAK,UAAU,aA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js {\n export interface Object3DDataContent {\n width: float;\n height: float;\n depth: float;\n }\n /** Base parameters for {@link gdjs.RuntimeObject3D} */\n export interface Object3DData extends ObjectData {\n /** The base parameters of the RuntimeObject3D */\n content: Object3DDataContent;\n }\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: Object3DData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._renderer.reinitialize(this, parent);\n }\n\n protected _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined)\n this.setDepth(initialInstanceData.depth);\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._z + this._minZ;\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth === 0) {\n return;\n }\n const scaleZ = depth / unscaledDepth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[2] *= scaleZ;\n this._innerArea.max[2] *= scaleZ;\n } else {\n this.setScaleZ(scaleZ);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAeS,eACG,GAAK,mBACiB,CAwB9B,YACE,EACA,EACA,CACA,MAAM,EAAQ,GAxBR,QAAY,EACZ,WAAe,EACf,WAAe,EACf,aAAiB,EACjB,eAAqB,GAMrB,gBAAoB,EAMpB,gBAAoB,EACpB,oBAAwB,EAQ9B,KAAK,UAAU,aAAa,KAAM,GAG1B,eAAgB,CACxB,KAAM,GAAS,KAAK,cACpB,MAAO,IAAI,GAAK,8BACd,KACA,KAAK,mBACL,GAIM,uBAA8B,CACtC,KAAK,cAAc,aAAa,KAAM,KAAK,aAG7C,aAAkD,CAChD,MAAO,OAAM,cAGf,qBAAsB,CAGpB,MAAO,MAAK,cAAc,sBAG5B,uCAAuC,EAAmC,CACxE,MAAM,uCAAuC,GACzC,EAAoB,QAAU,QAChC,KAAK,SAAS,EAAoB,OAMtC,KAAK,EAAgB,CACnB,AAAI,IAAM,KAAK,IACf,MAAK,GAAK,EACV,K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GAAS,KAAK,YACd,EAAS,KAAK,YACd,EAAS,KAAK,YACpB,MAAO,KAAW,GAAU,IAAW,EACnC,EACA,KAAK,IAAI,EAAS,EAAS,EAAQ,EAAI,GAQ7C,WAAmB,CACjB,MAAO,MAAK,IAAI,KAAK,SAGvB,MAAM,EAAiB,CACrB,AAAI,IAAW,KAAK,WAGpB,MAAK,UAAY,EACjB,KAAK,cAAc,cAGrB,YAAsB,CACpB,MAAO,MAAK,WArVC,AAxBV,EAwBU,iBAAmB,GAAI,OAAM,QAxBvC,EAAM,0BAfL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(T){let Q;(function(r){const e=new T.Logger("AdMob"),J={appOpen:{android:"ca-app-pub-3940256099942544/9257395921",ios:"ca-app-pub-3940256099942544/5575463023"},banner:{android:"ca-app-pub-3940256099942544/6300978111",ios:"ca-app-pub-3940256099942544/2934735716"},interstitial:{android:"ca-app-pub-3940256099942544/1033173712",ios:"ca-app-pub-3940256099942544/4411468910"},interstitialVideo:{android:"ca-app-pub-3940256099942544/8691691433",ios:"ca-app-pub-3940256099942544/5135589807"},rewarded:{android:"ca-app-pub-3940256099942544/5224354917",ios:"ca-app-pub-3940256099942544/1712485313"},rewardedInterstitial:{android:"ca-app-pub-3940256099942544/5354046379",ios:"ca-app-pub-3940256099942544/6978759866"},native:{android:"ca-app-pub-3940256099942544/2247696110",ios:"ca-app-pub-3940256099942544/3986624511"},nativeVideo:{android:"ca-app-pub-3940256099942544/1044960115",ios:"ca-app-pub-3940256099942544/2521693316"}};let l;(function(s){s[s.BANNER=0]="BANNER",s[s.LARGE_BANNER=1]="LARGE_BANNER",s[s.MEDIUM_RECTANGLE=2]="MEDIUM_RECTANGLE",s[s.FULL_BANNER=3]="FULL_BANNER",s[s.LEADERBOARD=4]="LEADERBOARD",s[s.SMART_BANNER=5]="SMART_BANNER"})(l||(l={}));const X={BANNER:0,LARGE_BANNER:1,MEDIUM_RECTANGLE:2,FULL_BANNER:3,LEADERBOARD:4,SMART_BANNER:5};let C;(function(n){n[n.Portrait=1]="Portrait",n[n.PortraitUpsideDown=2]="PortraitUpsideDown",n[n.LandscapeRight=3]="LandscapeRight",n[n.LandscapeLeft=4]="LandscapeLeft"})(C||(C={}));let G=!1,k=!1,q=!1,R,K=5,W=!1,S=!1,p=!1,O=!1,c,h=!1,A=!1,v=!1,E=!1,u,g=!1,I=!1,V=!1,y=!1,f,L=!1,N=!1,_=!1,F=!1,x=!1,w,B=!1,b=!1,U=!1,P=!1,m=!1,H="0";document.addEventListener("deviceready",async()=>{e.info("Starting AdMob."),k=!0,await admob.start(),e.info("AdMob successfully started."),k=!1,G=!0},!1);const d=async()=>{if(typeof cordova=="undefined")return e.warn("We are not on mobile, AdMob will not be available."),!1;if(typeof admob=="undefined")return e.warn("AdMob has not been configured properly."),!1;if(!G){if(k){let t=0;for(;!G&&t<5e3;)await new Promise(a=>setTimeout(a,100)),t+=100}if(!G)return e.warn("AdMob is not started."),!1}return!0},D=(t,a,o)=>{if(typeof cordova=="undefined"){e.warn("Cordova is not available.");return}return cordova.platformId==="android"?q?J[o].android:t:cordova.platformId==="ios"?q?J[o].ios:a:(e.error("Unsupported platform: ",cordova.platformId),null)};r.setTestMode=async t=>{!await d()||(e.info("Setting AdMob test mode to:",t),q=t)},r.isAppOpenLoading=()=>g,r.isAppOpenReady=()=>I,r.isAppOpenShowing=()=>V,r.isAppOpenErrored=()=>y,r.loadAppOpen=async(t,a,o,i)=>{if(!await d()||g||V)return;const n=D(t,a,"appOpen");if(!!n){g=!0,I=!1,y=!1,u=new admob.AppOpenAd({adUnitId:n,orientation:o?4:1}),u.on("load",()=>{I=!0,g=!1}),u.on("loadfail",()=>{g=!1,y=!0}),u.on("show",()=>{V=!0,I=!1}),u.on("showfail",()=>{V=!1,y=!0}),u.on("dismiss",()=>{V=!1});try{e.info("Loading Admob App Open."),await u.load(),e.info("AdMob App Open successfully loaded."),g=!1,I=!0,i&&r.showAppOpen()}catch(z){e.error("Error while loading an App Open:",z),g=!1,I=!1,y=!0}}},r.showAppOpen=async()=>{if(!!await d()){if(!u){e.warn("App Open has not been set up, call loadAppOpen first.");return}if(!I){e.info("App Open not loaded yet, cannot display it.");return}y=!1;try{e.info("Showing AdMob App Open."),await u.show()}catch(t){e.error("Error while showing an AdMob App Open:",t),V=!1,y=!0}}},r.isBannerConfigured=()=>W,r.isBannerLoaded=()=>S,r.isBannerShowing=()=>p,r.isBannerErrored=()=>O,r.setBannerAdSizeType=t=>{K=X[t]||5},r.setupBanner=async(t,a,o)=>{if(!await d())return;const i=D(t,a,"banner");!i||(R&&p&&(e.info("Banner already visible, hiding it to display new one."),await r.hideBanner()),W=!1,S=!1,R=new admob.BannerAd({adUnitId:i,position:o?"top":"bottom",size:K}),R.on("load",()=>{p=!0,S=!0}),R.on("loadfail",()=>{p=!1,S=!1,O=!0}),W=!0)},r.showBanner=async()=>{if(!R){e.info("Banner not configured, use setupBanner first.");return}if(p){e.info("Banner already visible. Ignoring.");return}O=!1;try{e.info("Showing AdMob banner."),await R.show(),S&&(p=!0)}catch(t){p=!1,O=!0,e.error("Error while showing an AdMob banner:",t)}},r.hideBanner=async()=>{if(!!await d()){if(!R||!p){e.warn("No banner is being shown.");return}await R.hide(),p=!1}},r.isInterstitialLoading=()=>h,r.isInterstitialReady=()=>A,r.isInterstitialShowing=()=>v,r.isInterstitialErrored=()=>E,r.loadInterstitial=async(t,a,o)=>{if(!await d()||h||v)return;const i=D(t,a,"interstitial");if(!!i){h=!0,A=!1,E=!1,c=new admob.InterstitialAd({adUnitId:i,npa:H}),c.on("load",()=>{A=!0,h=!1}),c.on("loadfail",()=>{h=!1,E=!0}),c.on("show",()=>{v=!0,A=!1}),c.on("showfail",()=>{v=!1,E=!0}),c.on("dismiss",()=>{v=!1});try{e.info("Loading Admob interstitial."),await c.load(),e.info("AdMob interstitial successfully loaded."),h=!1,A=!0,o&&r.showInterstitial()}catch(n){e.error("Error while loading a interstitial:",n),h=!1,A=!1,E=!0}}},r.showInterstitial=async()=>{if(!!await d()){if(!c){e.warn("Interstitial has not been set up, call loadInterstitial first.");return}if(!A){e.info("Interstitial not loaded yet, cannot display it.");return}E=!1;try{e.info("Showing AdMob interstitial."),await c.show()}catch(t){e.error("Error while showing an AdMob interstitial:",t),v=!1,E=!0}}},r.isRewardedInterstitialLoading=()=>L,r.isRewardedInterstitialReady=()=>N,r.isRewardedInterstitialShowing=()=>_,r.isRewardedInterstitialErrored=()=>x,r.wasRewardedInterstitialRewardReceived=function(t){const a=F;return t&&(F=!1),a},r.loadRewardedInterstitial=async(t,a,o)=>{if(!await d()||L||_)return;const i=D(t,a,"rewardedInterstitial");if(!!i){L=!0,N=!1,x=!1,f=new admob.RewardedInterstitialAd({adUnitId:i,npa:H}),f.on("load",()=>{N=!0,L=!1}),f.on("loadfail",()=>{L=!1,x=!0}),f.on("show",()=>{_=!0,N=!1}),f.on("showfail",()=>{_=!1,x=!0}),f.on("dismiss",()=>{_=!1}),f.on("reward",()=>{F=!0});try{e.info("Loading AdMob rewarded interstitial."),await f.load(),e.info("AdMob rewarded interstitial successfully loaded."),L=!1,N=!0,o&&r.showRewardedInterstitial()}catch(n){L=!1,N=!1,x=!0,e.error("Error while loading a rewarded interstitial:",n)}}},r.showRewardedInterstitial=async()=>{if(!!await d()){if(!f){e.warn("interstitial has not been set up, call loadRewardedInterstitial first.");return}N||e.info("Rewarded interstitial not loaded yet, cannot display it."),x=!1;try{e.info("Showing AdMob rewarded interstitial."),await f.show()}catch(t){e.error("Error while showing an AdMob rewarded interstitial:",t),_=!1,x=!0}}},r.markRewardedInterstitialRewardAsClaimed=()=>{F=!1},r.isRewardedVideoLoading=()=>B,r.isRewardedVideoReady=()=>b,r.isRewardedVideoShowing=()=>U,r.isRewardedVideoErrored=()=>m,r.wasRewardedVideoRewardReceived=function(t){const a=P;return t&&(P=!1),a},r.loadRewardedVideo=async(t,a,o)=>{if(!await d()||B||U)return;const i=D(t,a,"rewarded");if(!!i){B=!0,b=!1,m=!1,w=new admob.RewardedAd({adUnitId:i,npa:H}),w.on("load",()=>{b=!0,B=!1}),w.on("loadfail",()=>{B=!1,m=!0}),w.on("show",()=>{U=!0,b=!1}),w.on("showfail",()=>{U=!1,m=!0}),w.on("dismiss",()=>{U=!1}),w.on("reward",()=>{P=!0});try{e.info("Loading AdMob rewarded video."),await w.load(),e.info("AdMob rewarded video successfully loaded."),B=!1,b=!0,o&&r.showRewardedVideo()}catch(n){B=!1,b=!1,m=!0,e.error("Error while loading a rewarded video:",n)}}},r.showRewardedVideo=async()=>{if(!!await d()){if(!w){e.warn("Video has not been set up, call loadRewardedVideo first.");return}b||e.info("Rewarded video not loaded yet, cannot display it."),m=!1;try{e.info("Showing AdMob rewarded video."),await w.show()}catch(t){e.error("Error while showing an AdMob rewarded video:",t),U=!1,m=!0}}},r.markRewardedVideoRewardAsClaimed=()=>{P=!1}})(Q=T.adMob||(T.adMob={}))})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(T){let Q;(function(r){const e=new T.Logger("AdMob"),J={appOpen:{android:"ca-app-pub-3940256099942544/9257395921",ios:"ca-app-pub-3940256099942544/5575463023"},banner:{android:"ca-app-pub-3940256099942544/6300978111",ios:"ca-app-pub-3940256099942544/2934735716"},interstitial:{android:"ca-app-pub-3940256099942544/1033173712",ios:"ca-app-pub-3940256099942544/4411468910"},interstitialVideo:{android:"ca-app-pub-3940256099942544/8691691433",ios:"ca-app-pub-3940256099942544/5135589807"},rewarded:{android:"ca-app-pub-3940256099942544/5224354917",ios:"ca-app-pub-3940256099942544/1712485313"},rewardedInterstitial:{android:"ca-app-pub-3940256099942544/5354046379",ios:"ca-app-pub-3940256099942544/6978759866"},native:{android:"ca-app-pub-3940256099942544/2247696110",ios:"ca-app-pub-3940256099942544/3986624511"},nativeVideo:{android:"ca-app-pub-3940256099942544/1044960115",ios:"ca-app-pub-3940256099942544/2521693316"}};let l;(function(s){s[s.BANNER=0]="BANNER",s[s.LARGE_BANNER=1]="LARGE_BANNER",s[s.MEDIUM_RECTANGLE=2]="MEDIUM_RECTANGLE",s[s.FULL_BANNER=3]="FULL_BANNER",s[s.LEADERBOARD=4]="LEADERBOARD",s[s.SMART_BANNER=5]="SMART_BANNER"})(l||(l={}));const X={BANNER:0,LARGE_BANNER:1,MEDIUM_RECTANGLE:2,FULL_BANNER:3,LEADERBOARD:4,SMART_BANNER:5};let C;(function(n){n[n.Portrait=1]="Portrait",n[n.PortraitUpsideDown=2]="PortraitUpsideDown",n[n.LandscapeRight=3]="LandscapeRight",n[n.LandscapeLeft=4]="LandscapeLeft"})(C||(C={}));let G=!1,k=!1,q=!1,R,K=5,W=!1,S=!1,p=!1,O=!1,c,h=!1,A=!1,v=!1,E=!1,u,g=!1,I=!1,V=!1,y=!1,f,L=!1,N=!1,_=!1,F=!1,x=!1,w,B=!1,b=!1,U=!1,P=!1,m=!1,H="0";document.addEventListener("deviceready",async()=>{e.info("Starting AdMob."),k=!0,await admob.start(),e.info("AdMob successfully started."),k=!1,G=!0},!1);const d=async()=>{if(typeof cordova=="undefined")return e.warn("We are not on mobile, AdMob will not be available."),!1;if(typeof admob=="undefined")return e.warn("AdMob has not been configured properly."),!1;if(!G){if(k){let t=0;for(;!G&&t<5e3;)await new Promise(a=>setTimeout(a,100)),t+=100}if(!G)return e.warn("AdMob is not started."),!1}return!0},D=(t,a,o)=>{if(typeof cordova=="undefined"){e.warn("Cordova is not available.");return}return cordova.platformId==="android"?q?J[o].android:t:cordova.platformId==="ios"?q?J[o].ios:a:(e.error("Unsupported platform: ",cordova.platformId),null)};r.setTestMode=async t=>{!await d()||(e.info("Setting AdMob test mode to:",t),q=t)},r.isAppOpenLoading=()=>g,r.isAppOpenReady=()=>I,r.isAppOpenShowing=()=>V,r.isAppOpenErrored=()=>y,r.loadAppOpen=async(t,a,o,i)=>{if(!await d()||g||V)return;const n=D(t,a,"appOpen");if(!!n){g=!0,I=!1,y=!1,u=new admob.AppOpenAd({adUnitId:n,orientation:o?4:1}),u.on("load",()=>{I=!0,g=!1}),u.on("loadfail",()=>{g=!1,y=!0}),u.on("show",()=>{V=!0,I=!1}),u.on("showfail",()=>{V=!1,y=!0}),u.on("dismiss",()=>{V=!1});try{e.info("Loading Admob App Open."),await u.load(),e.info("AdMob App Open successfully loaded."),g=!1,I=!0,i&&r.showAppOpen()}catch(z){e.error("Error while loading an App Open:",z),g=!1,I=!1,y=!0}}},r.showAppOpen=async()=>{if(!!await d()){if(!u){e.warn("App Open has not been set up, call loadAppOpen first.");return}if(!I){e.info("App Open not loaded yet, cannot display it.");return}y=!1;try{e.info("Showing AdMob App Open."),await u.show()}catch(t){e.error("Error while showing an AdMob App Open:",t),V=!1,y=!0}}},r.isBannerConfigured=()=>W,r.isBannerLoaded=()=>S,r.isBannerShowing=()=>p,r.isBannerErrored=()=>O,r.setBannerAdSizeType=t=>{K=X[t]||5},r.setupBanner=async(t,a,o)=>{if(!await d())return;const i=D(t,a,"banner");!i||(R&&p&&(e.info("Banner already visible, hiding it to display new one."),await r.hideBanner()),W=!1,S=!1,R=new admob.BannerAd({adUnitId:i,position:o?"top":"bottom",size:K,offset:0}),R.on("load",()=>{p=!0,S=!0}),R.on("loadfail",()=>{p=!1,S=!1,O=!0}),W=!0)},r.showBanner=async()=>{if(!R){e.info("Banner not configured, use setupBanner first.");return}if(p){e.info("Banner already visible. Ignoring.");return}O=!1;try{e.info("Showing AdMob banner."),await R.show(),S&&(p=!0)}catch(t){p=!1,O=!0,e.error("Error while showing an AdMob banner:",t)}},r.hideBanner=async()=>{if(!!await d()){if(!R||!p){e.warn("No banner is being shown.");return}await R.hide(),p=!1}},r.isInterstitialLoading=()=>h,r.isInterstitialReady=()=>A,r.isInterstitialShowing=()=>v,r.isInterstitialErrored=()=>E,r.loadInterstitial=async(t,a,o)=>{if(!await d()||h||v)return;const i=D(t,a,"interstitial");if(!!i){h=!0,A=!1,E=!1,c=new admob.InterstitialAd({adUnitId:i,npa:H}),c.on("load",()=>{A=!0,h=!1}),c.on("loadfail",()=>{h=!1,E=!0}),c.on("show",()=>{v=!0,A=!1}),c.on("showfail",()=>{v=!1,E=!0}),c.on("dismiss",()=>{v=!1});try{e.info("Loading Admob interstitial."),await c.load(),e.info("AdMob interstitial successfully loaded."),h=!1,A=!0,o&&r.showInterstitial()}catch(n){e.error("Error while loading a interstitial:",n),h=!1,A=!1,E=!0}}},r.showInterstitial=async()=>{if(!!await d()){if(!c){e.warn("Interstitial has not been set up, call loadInterstitial first.");return}if(!A){e.info("Interstitial not loaded yet, cannot display it.");return}E=!1;try{e.info("Showing AdMob interstitial."),await c.show()}catch(t){e.error("Error while showing an AdMob interstitial:",t),v=!1,E=!0}}},r.isRewardedInterstitialLoading=()=>L,r.isRewardedInterstitialReady=()=>N,r.isRewardedInterstitialShowing=()=>_,r.isRewardedInterstitialErrored=()=>x,r.wasRewardedInterstitialRewardReceived=function(t){const a=F;return t&&(F=!1),a},r.loadRewardedInterstitial=async(t,a,o)=>{if(!await d()||L||_)return;const i=D(t,a,"rewardedInterstitial");if(!!i){L=!0,N=!1,x=!1,f=new admob.RewardedInterstitialAd({adUnitId:i,npa:H}),f.on("load",()=>{N=!0,L=!1}),f.on("loadfail",()=>{L=!1,x=!0}),f.on("show",()=>{_=!0,N=!1}),f.on("showfail",()=>{_=!1,x=!0}),f.on("dismiss",()=>{_=!1}),f.on("reward",()=>{F=!0});try{e.info("Loading AdMob rewarded interstitial."),await f.load(),e.info("AdMob rewarded interstitial successfully loaded."),L=!1,N=!0,o&&r.showRewardedInterstitial()}catch(n){L=!1,N=!1,x=!0,e.error("Error while loading a rewarded interstitial:",n)}}},r.showRewardedInterstitial=async()=>{if(!!await d()){if(!f){e.warn("interstitial has not been set up, call loadRewardedInterstitial first.");return}N||e.info("Rewarded interstitial not loaded yet, cannot display it."),x=!1;try{e.info("Showing AdMob rewarded interstitial."),await f.show()}catch(t){e.error("Error while showing an AdMob rewarded interstitial:",t),_=!1,x=!0}}},r.markRewardedInterstitialRewardAsClaimed=()=>{F=!1},r.isRewardedVideoLoading=()=>B,r.isRewardedVideoReady=()=>b,r.isRewardedVideoShowing=()=>U,r.isRewardedVideoErrored=()=>m,r.wasRewardedVideoRewardReceived=function(t){const a=P;return t&&(P=!1),a},r.loadRewardedVideo=async(t,a,o)=>{if(!await d()||B||U)return;const i=D(t,a,"rewarded");if(!!i){B=!0,b=!1,m=!1,w=new admob.RewardedAd({adUnitId:i,npa:H}),w.on("load",()=>{b=!0,B=!1}),w.on("loadfail",()=>{B=!1,m=!0}),w.on("show",()=>{U=!0,b=!1}),w.on("showfail",()=>{U=!1,m=!0}),w.on("dismiss",()=>{U=!1}),w.on("reward",()=>{P=!0});try{e.info("Loading AdMob rewarded video."),await w.load(),e.info("AdMob rewarded video successfully loaded."),B=!1,b=!0,o&&r.showRewardedVideo()}catch(n){B=!1,b=!1,m=!0,e.error("Error while loading a rewarded video:",n)}}},r.showRewardedVideo=async()=>{if(!!await d()){if(!w){e.warn("Video has not been set up, call loadRewardedVideo first.");return}b||e.info("Rewarded video not loaded yet, cannot display it."),m=!1;try{e.info("Showing AdMob rewarded video."),await w.show()}catch(t){e.error("Error while showing an AdMob rewarded video:",t),U=!1,m=!0}}},r.markRewardedVideoRewardAsClaimed=()=>{P=!1}})(Q=T.adMob||(T.adMob={}))})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=admobtools.js.map
|