@hology/core 0.0.120 → 0.0.122
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/config/project-config.js +1 -1
- package/dist/controllers/base-game-controller.js +1 -1
- package/dist/csm.js +1 -1
- package/dist/effects/particles/examples.js +1 -1
- package/dist/effects/particles/particle-system-config.js +1 -1
- package/dist/effects/vfx/behaviours.js +1 -1
- package/dist/effects/vfx/index.js +1 -1
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/rates.js +1 -1
- package/dist/effects/vfx/stretched-sprite.js +1 -1
- package/dist/effects/vfx/trail-renderer.js +1 -1
- package/dist/effects/vfx/vfx-actor.js +1 -1
- package/dist/effects/vfx/vfx-asset.js +1 -1
- package/dist/effects/vfx/vfx-collision-behaviour.js +1 -1
- package/dist/effects/vfx/vfx-defs.js +1 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/effects/vfx/vfx-old-materializer.js +1 -1
- package/dist/effects/vfx/vfx-param.js +1 -1
- package/dist/effects/vfx/vfx-renderers.js +1 -1
- package/dist/effects/vfx/vfx-service.js +1 -1
- package/dist/effects/vfx/zones.js +1 -1
- package/dist/game-component/component-decorators.js +1 -1
- package/dist/game-component/game-component.js +1 -1
- package/dist/gameplay/actors/actor.js +1 -1
- package/dist/gameplay/actors/builtin/camera-actor.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/modes.js +1 -1
- package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/scene-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/volume-editor-component.js +1 -1
- package/dist/gameplay/actors/builtin/index.js +1 -1
- package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
- package/dist/gameplay/actors/builtin/positional-audio-actor.js +1 -1
- package/dist/gameplay/actors/builtin/post-process-volume-actor.js +1 -1
- package/dist/gameplay/actors/builtin/spawn-point.js +1 -1
- package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
- package/dist/gameplay/actors/camera/camera-component.js +1 -1
- package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -1
- package/dist/gameplay/actors/component.js +1 -1
- package/dist/gameplay/actors/factory.js +1 -1
- package/dist/gameplay/actors/index.js +1 -1
- package/dist/gameplay/actors/internal/component-init.js +1 -1
- package/dist/gameplay/actors/internal/container-map.js +1 -1
- package/dist/gameplay/ai/behavior-tree/bt.js +1 -1
- package/dist/gameplay/ai/behavior-tree/move.js +1 -1
- package/dist/gameplay/ai/build-tile.js +1 -1
- package/dist/gameplay/ai/dynamic-tiled-navmesh.js +1 -1
- package/dist/gameplay/ai/dynamic-tiled-navmesh.worker.js +1 -1
- package/dist/gameplay/ai/index.js +1 -1
- package/dist/gameplay/ai/navigation.js +1 -1
- package/dist/gameplay/animation/anim-sm.js +1 -1
- package/dist/gameplay/animation/root-motion.js +1 -1
- package/dist/gameplay/env.js +1 -1
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.d.ts +9 -0
- package/dist/gameplay/initiate.d.ts.map +1 -1
- package/dist/gameplay/initiate.js +2 -2
- package/dist/gameplay/inject.js +1 -1
- package/dist/gameplay/input/index.js +1 -1
- package/dist/gameplay/input/input-service.js +1 -1
- package/dist/gameplay/input/input.js +1 -1
- package/dist/gameplay/input/keybind.js +1 -1
- package/dist/gameplay/polyfill.js +1 -1
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/abstract-physics-system.js +1 -1
- package/dist/gameplay/services/physics/collision-contact.js +1 -1
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/pointer-events.js +1 -1
- package/dist/gameplay/services/render.js +1 -1
- package/dist/gameplay/services/shader-provider.js +1 -1
- package/dist/gameplay/services/world.js +1 -1
- package/dist/index.js +1 -1
- package/dist/rendering/color-pass.d.ts.map +1 -1
- package/dist/rendering/color-pass.js +2 -2
- package/dist/rendering/shader-override.js +1 -1
- package/dist/rendering/tone-mapping.js +1 -1
- package/dist/rendering.d.ts +3 -0
- package/dist/rendering.d.ts.map +1 -1
- package/dist/rendering.js +2 -2
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/assets-provider.js +1 -1
- package/dist/scene/bootstrap.d.ts +5 -1
- package/dist/scene/bootstrap.d.ts.map +1 -1
- package/dist/scene/bootstrap.js +2 -2
- package/dist/scene/collision/collision-shape-import.js +1 -1
- package/dist/scene/collision/collision-shape.js +1 -1
- package/dist/scene/landscape/landscape-manager.js +1 -1
- package/dist/scene/landscape/landscape.js +1 -1
- package/dist/scene/landscape/utils.js +1 -1
- package/dist/scene/materializer.d.ts +3 -1
- package/dist/scene/materializer.d.ts.map +1 -1
- package/dist/scene/materializer.js +2 -2
- package/dist/scene/materials/grass-foliage.js +1 -1
- package/dist/scene/materials/grass.js +1 -1
- package/dist/scene/materials/utils/material-painting.js +1 -1
- package/dist/scene/materials/utils/noise.glsl.js +1 -1
- package/dist/scene/materials/water.js +1 -1
- package/dist/scene/model.d.ts +11 -0
- package/dist/scene/model.d.ts.map +1 -1
- package/dist/scene/model.js +2 -2
- package/dist/scene/objects/prefab.js +1 -1
- package/dist/scene/objects/ramp-geometry.js +1 -1
- package/dist/scene/objects/shapes.js +1 -1
- package/dist/scene/objects/stairs-geometry.js +1 -1
- package/dist/scene/runtime-asset-service.js +1 -1
- package/dist/scene/runtime-backend-service.js +1 -1
- package/dist/scene/runtime-bundled-backend-service.js +1 -1
- package/dist/scene/scene-data-service.js +1 -1
- package/dist/scene/sky.js +1 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/decal-standard-shader.js +1 -1
- package/dist/shader/builtin/decal-unlit-shader.js +1 -1
- package/dist/shader/builtin/index.js +1 -1
- package/dist/shader/builtin/lambert-shader.js +1 -1
- package/dist/shader/builtin/landscape-composite-shader.js +1 -1
- package/dist/shader/builtin/landscape-shader.js +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/builtin/unlit-shader.js +1 -1
- package/dist/shader/decal-shader.js +1 -1
- package/dist/shader/index.js +1 -1
- package/dist/shader/parameter.js +1 -1
- package/dist/shader/shader.js +1 -1
- package/dist/shader/sprite-shader.js +1 -1
- package/dist/shader/trail-shader.js +1 -1
- package/dist/shader-nodes/bulge.js +1 -1
- package/dist/shader-nodes/decal.js +1 -1
- package/dist/shader-nodes/depth.js +1 -1
- package/dist/shader-nodes/effects.js +1 -1
- package/dist/shader-nodes/glsl-node.js +1 -1
- package/dist/shader-nodes/index.js +1 -1
- package/dist/shader-nodes/landscape.js +1 -1
- package/dist/shader-nodes/layers.js +1 -1
- package/dist/shader-nodes/math.js +1 -1
- package/dist/shader-nodes/particle.js +1 -1
- package/dist/shader-nodes/scene-sample.js +1 -1
- package/dist/shader-nodes/shapes.js +1 -1
- package/dist/shader-nodes/texture-sequence.js +1 -1
- package/dist/shader-nodes/time.js +1 -1
- package/dist/shader-nodes/voronoi.js +1 -1
- package/dist/test/injection.test.js +1 -1
- package/dist/utils/async.js +1 -1
- package/dist/utils/buffer.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/curve.js +1 -1
- package/dist/utils/files.js +1 -1
- package/dist/utils/materials.js +1 -1
- package/dist/utils/math.js +1 -1
- package/dist/utils/mesh.js +1 -1
- package/dist/utils/polyfill.js +1 -1
- package/dist/utils/three/depth-pass.js +1 -1
- package/dist/utils/three/gpu-stats-panel.js +1 -1
- package/dist/utils/three/line-sphere.js +1 -1
- package/dist/utils/three/outline-pass.js +1 -1
- package/dist/utils/three/positional-audio-helper.js +1 -1
- package/dist/utils/three/stats.js +1 -1
- package/dist/utils/three/transform-controls.js +1 -1
- package/dist/utils/three/traverse.js +1 -1
- package/dist/utils/type.js +1 -1
- package/dist/utils/uuid.js +1 -1
- package/dist/utils/voxel-bitset.js +1 -1
- package/dist/worker/index.js +1 -1
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as t,__metadata as i}from"tslib";import{ContainerInstance as n}from"typedi";import{Service as o}from"typedi";import{initComponents as e}from"./internal/component-init.js";import{activeContainerInstance as r,containerRefMap as a}from"./internal/container-map.js";let s=class{constructor(t,i){this.container=t,this.env=i}async create(t,i,n,o){const e=this.container;r.value=e;const s=(1e4*Math.random()).toString();e.set({id:s,type:t,transient:!0});const c=e.get(s);return r.value=null,e.remove(t),a.set(c,e),i&&c.object.position.copy(i),n&&c.object.rotation.copy(n),!0!==o&&await this.initActor(c),c}async initActor(t){await e(t,t,this.env.inEditor??!1),await t.onInit(),t.__isInitialised=!0}};s=t([o(),i("design:paramtypes",[n,Object])],s);export{s as ActorFactory};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export{CameraActor}from"./builtin/camera-actor.js";export{CameraComponent}from"./camera/camera-component.js";export{ThirdPersonCameraComponent,ThirdPartyCameraComponent}from"./camera/third-person-camera-component.js";export{SpawnPoint}from"./builtin/spawn-point.js";export{TriggerVolume,TriggerVolumeComponent}from"./builtin/trigger-volume.js";export{PositionalAudioActor,PositionalAudioComponent}from"./builtin/positional-audio-actor.js";export*from"./builtin/components/mesh-component.js";export*from"./builtin/components/character/character-movement.js";export*from"./builtin/components/character/modes.js";export*from"./builtin/components/character/character-animation.js";/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{ActorComponent as o}from"../component.js";const n=new WeakMap;export async function initComponents(t,c,i=!1){const r=[];for(const s of Object.values(t))if(s instanceof o||null!=s?.constructor&&!0===s.constructor.__isActorComponent){if(i&&!s.constructor.__inEditor)continue;if(!i&&s.constructor.__onlyEditor)continue;const o=s;if(o.actor=c,n.has(o))continue;n.set(o,!0),await o.onInit(),r.push(initComponents(s,c,i))}return Promise.all(r)}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export class Node{}export var NodeState;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILURE=1]="FAILURE",t[t.RUNNING=2]="RUNNING"}(NodeState||(NodeState={}));export class LeafNode extends Node{}export class ActionNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action()}}export class SuccessNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action(),NodeState.SUCCESS}}export class FailNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action(),NodeState.FAILURE}}export class ConditionNode extends LeafNode{constructor(t){super(),this.condition=t}tick(){return this.condition()?NodeState.SUCCESS:NodeState.FAILURE}}export class CompositeNode extends Node{constructor(){super(...arguments),this.children=[]}addChild(t){this.children.push(t)}}export class SequenceNode extends CompositeNode{constructor(){super(...arguments),this.current=0}tick(t){if(0===this.children.length)return this.reset(),NodeState.SUCCESS;const e=this.children[this.current].tick(t);if(e===NodeState.FAILURE)return this.reset(),NodeState.FAILURE;if(e===NodeState.SUCCESS){if(this.current==this.children.length-1)return this.reset(),NodeState.SUCCESS;this.current++}return NodeState.SUCCESS}reset(){this.current=0}}export class SelectorNode extends CompositeNode{tick(t){for(const e of this.children){const s=e.tick(t);if(s!==NodeState.FAILURE)return s}return NodeState.FAILURE}}export class DecoratorNode extends Node{constructor(t){super(),this.child=t}}export class InverterNode extends DecoratorNode{tick(t){const e=this.child.tick(t);return e===NodeState.SUCCESS?NodeState.FAILURE:e===NodeState.FAILURE?NodeState.SUCCESS:e}}export class RepeatTimesNode extends DecoratorNode{constructor(t,e=1/0){super(t),this.counter=0,this.limit=e}tick(t){for(;this.counter<this.limit;){if(this.child.tick(t)===NodeState.RUNNING)return NodeState.RUNNING;this.counter++}return this.counter=0,NodeState.SUCCESS}}export class RepeatNode extends DecoratorNode{constructor(t){super(t)}tick(t){return this.child.tick(t),NodeState.RUNNING}}export class RepeatUntilNode extends DecoratorNode{constructor(t,e){super(t),this.condition=e}tick(t){if(this.condition())return NodeState.SUCCESS;return this.child.tick(t)===NodeState.FAILURE?NodeState.FAILURE:NodeState.RUNNING}}export class RepeatUntilFailNode extends DecoratorNode{constructor(t){super(t)}tick(t){return this.child.tick(t)===NodeState.FAILURE?NodeState.FAILURE:NodeState.RUNNING}}export class DelayNode extends DecoratorNode{constructor(t,e){super(t),this.state=NodeState.RUNNING,this.elapsed=null,this.delay=e}tick(t){return null===this.elapsed&&(this.elapsed=0),this.elapsed+=1e3*t,this.elapsed>=this.delay&&(this.state=this.child.tick(t),this.state!==NodeState.RUNNING&&(this.elapsed=null)),this.state}}export class DelayAfterNode extends DecoratorNode{constructor(t,e){super(t),this.state=NodeState.RUNNING,this.elapsed=null,this.delay=e}tick(t){if(null==this.elapsed){if(this.state=this.child.tick(t),this.state===NodeState.RUNNING)return this.state;this.elapsed=0}return this.elapsed+=1e3*t,this.elapsed<this.delay?NodeState.RUNNING:(this.elapsed=null,this.state)}}export class WaitNode extends LeafNode{constructor(t,e){super(),this.delayMin=t,this.delayMax=e,this.elapsed=null,this.delay=this.delayMin,this.reset()}tick(t){return null===this.elapsed&&(this.elapsed=0),this.elapsed+=1e3*t,this.elapsed>=this.delay?(this.elapsed=null,this.reset(),NodeState.SUCCESS):NodeState.RUNNING}reset(){null!=this.delayMax?this.delay=(this.delayMax-this.delayMin)*Math.random()+this.delayMin:this.delay=this.delayMin}}export class CooldownNode extends DecoratorNode{constructor(t,e){super(t),this.cooldownTime=e,this.lastExecutionTime=null}tick(t){const e=Date.now();if(null===this.lastExecutionTime||e-this.lastExecutionTime>=this.cooldownTime){const s=this.child.tick(t);return s===NodeState.SUCCESS&&(this.lastExecutionTime=e),s}return NodeState.FAILURE}}export class TimerNode extends DecoratorNode{constructor(t,e){super(t),this.startTime=null,this.duration=e}tick(t){null===this.startTime&&(this.startTime=Date.now());return Date.now()-this.startTime<this.duration?this.child.tick(t):(this.startTime=null,NodeState.FAILURE)}}export class WeightedRandomSelectorNode extends CompositeNode{constructor(t){super(),this.weights=t,this.totalWeight=this.weights.reduce(((t,e)=>t+e),0)}getRandomIndex(){let t=Math.random()*this.totalWeight;for(let e=0;e<this.weights.length;e++)if(t-=this.weights[e],t<=0)return e;return this.weights.length-1}tick(t){const e=this.getRandomIndex();return this.children[e].tick(t)}}export class GuardNode extends DecoratorNode{constructor(t,e){super(t),this.condition=e}tick(t){return this.condition()?this.child.tick(t):NodeState.FAILURE}}export class ParallelSelectorNode extends CompositeNode{tick(t){let e=!0;for(const s of this.children){const i=s.tick(t);if(i===NodeState.SUCCESS)return NodeState.SUCCESS;i===NodeState.RUNNING&&(e=!1)}return e?NodeState.FAILURE:NodeState.RUNNING}}export class ParallelSequenceNode extends CompositeNode{tick(t){let e=!0;for(const s of this.children){const i=s.tick(t);if(i===NodeState.FAILURE)return NodeState.FAILURE;i===NodeState.RUNNING&&(e=!1)}return e?NodeState.SUCCESS:NodeState.RUNNING}}export class ThrottleNode extends DecoratorNode{constructor(t,e){super(t),this.duration=e,this.timeSinceLastTick=0}tick(t){return 0===this.timeSinceLastTick||this.timeSinceLastTick>this.duration?(this.timeSinceLastTick=t,this.child.tick(this.timeSinceLastTick)):(this.timeSinceLastTick+=t,NodeState.RUNNING)}}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{Vector3 as t}from"three";import{LeafNode as e,NodeState as o}from"./bt";import{clamp as n}from"../../../utils/math";export class CharacterMoveToNode extends e{constructor(t,e){super(),this.navigation=t,this.movement=e,this.distanceFrom=.5}tick(t){const e=this.movement.actor.object.position,c=null!=this.target?this.target():null;if(null==c)return this.movement.directionInput.vector.set(0,0),o.FAILURE;if(e.distanceTo(c)<this.distanceFrom)return this.movement.directionInput.vector.set(0,0),o.SUCCESS;const{success:m,path:a}=this.navigation.findPath(e,c);if(!m||a.length<2)return o.FAILURE;const h=a[1],u=i.subVectors(h,e);u.y=0,u.normalize(),this.movement.actor.object.getWorldDirection(r).normalize();const l=r.angleTo(u);s.crossVectors(r,u);const v=s.y<0?-l:l;return this.movement.rotationInput.rotation.y+=n(v,-.1,.1),this.movement.directionInput.togglePositiveY(!0),o.RUNNING}}const i=new t,r=new t,s=new t;/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{NavMeshCreateParams as e,Raw as t,RecastBuildContext as i,TriangleAreasArray as l,TrianglesArray as o,VerticesArray as r,allocCompactHeightfield as a,allocContourSet as s,allocHeightfield as n,allocPolyMesh as d,allocPolyMeshDetail as c,buildCompactHeightfield as h,buildContours as g,buildDistanceField as m,buildPolyMesh as u,buildPolyMeshDetail as b,buildRegions as f,calcGridSize as S,cloneRcConfig as R,createHeightfield as w,createNavMeshData as p,createRcConfig as C,erodeWalkableArea as M,filterLedgeSpans as _,filterLowHangingWalkableObstacles as x,filterWalkableLowHeightSpans as A,freeCompactHeightfield as k,freeContourSet as y,freeHeightfield as z,markWalkableTriangles as E,rasterizeTriangles as v,vec3 as T}from"@recast-navigation/core";import{dtIlog2 as B,dtNextPow2 as O}from"@recast-navigation/generators";import*as P from"three";export const buildConfig=({recastConfig:e,navMeshBounds:[t,i]})=>{const l=C(e),o=S(t,i,l.cs);l.width=o.width,l.height=o.height,l.minRegionArea=l.minRegionArea*l.minRegionArea,l.mergeRegionArea=l.mergeRegionArea*l.mergeRegionArea,l.tileSize=Math.floor(l.tileSize),l.borderSize=l.walkableRadius+3,l.width=l.tileSize+2*l.borderSize,l.height=l.tileSize+2*l.borderSize,l.detailSampleDist=l.detailSampleDist<.9?0:l.cs*l.detailSampleDist,l.detailSampleMaxError=l.ch*l.detailSampleMaxError;const r=Math.floor(l.tileSize),a=Math.floor((o.width+r-1)/r),s=Math.floor((o.height+r-1)/r),n=l.tileSize*l.cs,d=T.fromArray(t);let c=Math.min(Math.floor(B(O(a*s))),14);c>14&&(c=14);const h=22-c;return{config:l,orig:d,tileBits:c,polyBits:h,maxTiles:1<<c,maxPolysPerTile:1<<h,tcs:n,tileWidth:a,tileHeight:s}};export const buildTile=({positions:S,indices:C,navMeshBounds:T,recastConfig:B,tileX:O,tileY:H,tileBoundsMin:L,tileBoundsMax:G,keepIntermediates:D})=>{const $=new i,F=S,V=C.length,W=new r;W.copy(F);const I=C,K=C.length/3;(new o).copy(I);const X={tileX:O,tileY:H},Y=()=>{D||(X.compactHeightfield&&k(X.compactHeightfield),X.heightfield&&z(X.heightfield),X.contourSet&&y(X.contourSet))},N=e=>($.log(t.Module.RC_LOG_ERROR,e),Y(),{success:!1,error:e,tileIntermediates:X,buildContext:$}),{config:U}=buildConfig({recastConfig:B,navMeshBounds:T}),j=R(U),q=[...L],J=[...G];q[0]-=j.borderSize*j.cs,q[2]-=j.borderSize*j.cs,J[0]+=j.borderSize*j.cs,J[2]+=j.borderSize*j.cs,j.set_bmin(0,q[0]),j.set_bmin(1,q[1]),j.set_bmin(2,q[2]),j.set_bmax(0,J[0]),j.set_bmax(1,J[1]),j.set_bmax(2,J[2]),$.resetTimers(),$.startTimer(t.Module.RC_TIMER_TOTAL),$.log(t.Module.RC_LOG_PROGRESS,`Building tile at x: ${O}, y: ${H}`),$.log(t.Module.RC_LOG_PROGRESS,` - ${U.width} x ${U.height} cells`),$.log(t.Module.RC_LOG_PROGRESS,` - ${V/1e3}fK verts, ${K/1e3}K tris`);const Q=n();if(X.heightfield=Q,!w($,Q,j.width,j.height,q,J,j.cs,j.ch))return N("Could not create heightfield");const Z=((e,t,i)=>{const l=[],o=new P.Vector3,r=new P.Vector3,a=new P.Vector3,s=new P.Triangle;for(let n=0;n<t.length;n+=3){const d=t[n],c=t[n+1],h=t[n+2];o.fromArray(e,3*d),r.fromArray(e,3*c),a.fromArray(e,3*h),s.set(o,r,a),s.intersectsBox(i)&&l.push(d,c,h)}return l})(S,C,new P.Box3(new P.Vector3(q[0],q[1],q[2]),new P.Vector3(J[0],J[1],J[2]))),ee=Z.length/3,te=new o;te.copy(Z);const ie=new l;ie.resize(ee),E($,j.walkableSlopeAngle,W,V,te,ee,ie);const le=v($,W,V,te,ie,ee,Q,j.walkableClimb);if(ie.destroy(),!le)return N("Could not rasterize triangles");x($,j.walkableClimb,Q),_($,j.walkableHeight,j.walkableClimb,Q),A($,j.walkableHeight,Q);const oe=a();if(X.compactHeightfield=oe,!h($,j.walkableHeight,j.walkableClimb,Q,oe))return N("Could not build compact heightfield");if(D||(z(X.heightfield),X.heightfield=void 0),!M($,j.walkableRadius,oe))return N("Could not erode walkable area");if(!m($,oe))return N("Failed to build distance field");if(!f($,oe,j.borderSize,j.minRegionArea,j.mergeRegionArea))return N("Failed to build regions");const re=s();if(X.contourSet=re,!g($,oe,j.maxSimplificationError,j.maxEdgeLen,re,t.Module.RC_CONTOUR_TESS_WALL_EDGES))return N("Failed to create contours");const ae=d();if(!u($,re,j.maxVertsPerPoly,ae))return N("Failed to triangulate contours");const se=c();if(!b($,ae,oe,j.detailSampleDist,j.detailSampleMaxError,se))return N("Failed to build detail mesh");D||(k(oe),X.compactHeightfield=void 0,y(re),X.contourSet=void 0);for(let e=0;e<ae.npolys();e++)ae.areas(e)==t.Recast.WALKABLE_AREA&&ae.setAreas(e,0),0==ae.areas(e)&&ae.setFlags(e,1);const ne=new e;ne.setPolyMeshCreateParams(ae),ne.setPolyMeshDetailCreateParams(se),ne.setWalkableHeight(j.walkableHeight),ne.setWalkableRadius(j.walkableRadius),ne.setWalkableClimb(j.walkableClimb),ne.setCellSize(j.cs),ne.setCellHeight(j.ch),ne.setBuildBvTree(!0),ne.setTileX(O),ne.setTileY(H);const de=p(ne);return de.success?($.log(t.Module.RC_LOG_PROGRESS,`>> Polymesh: ${ae.nverts()} vertices ${ae.npolys()} polygons`),Y(),{success:!0,data:de.navMeshData,tileIntermediates:X,buildContext:$}):N("Failed to create Detour navmesh data")};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{NavMesh as t,NavMeshParams as s,Raw as e,UnsignedCharArray as i,recastConfigDefaults as o,statusToReadableString as n}from"recast-navigation";import{buildConfig as r,buildTile as a}from"./build-tile.js";import{Subject as h}from"rxjs";import{hasWorkerBuilder as l,createWorker as d}from"../../worker/index.js";import{hasSharedArrayBufferSupport as u}from"../../utils/buffer.js";const c=[];export class DynamicTiledNavMesh{constructor(e){this.navMeshVersion=0,this.onNavMeshUpdate=new h,this.workerRoundRobin=0;const i=e.navMeshBounds.min,n=e.navMeshBounds.max,a=[i.toArray(),n.toArray()],u=e.navMeshBounds.min;this.navMeshBoundsMin=i,this.navMeshBoundsMax=n,this.navMeshBounds=a,this.navMeshOrigin=u,this.cacheId=e.cacheId;const M={...o,...e.recastConfig};this.recastConfig=M;const f=new t,{tileWidth:v,tileHeight:m,tcs:g,maxPolysPerTile:w}=r({recastConfig:M,navMeshBounds:a});this.tileWidth=v,this.tileHeight=m,this.tcs=g;const B=s.create({orig:u,tileWidth:M.tileSize*M.cs,tileHeight:M.tileSize*M.ch,maxTiles:e.maxTiles,maxPolys:w});if(f.initTiled(B),this.navMesh=f,this.workers=[],l())for(let t=0;t<e.workers;t++){let t=c.pop();void 0===t&&(t=d()),t.onmessage=t=>{this.onResult(t)},this.workers.push(t)}}onResult(t){const{tileX:s,tileY:o,navMeshData:r}=t.data,a=new i;a.copy(r),this.navMesh.removeTile(this.navMesh.getTileRefAt(s,o,0));const h=this.navMesh.addTile(a,e.Module.DT_TILE_FREE_DATA,0);e.Detour.statusFailed(h.status)&&(console.error(e.Module.RC_LOG_WARNING,`Failed to add tile to nav mesh\n\ttx: ${s}, ty: ${o},status: ${n(h.status)} (${h.status})`),a.destroy()),this.navMeshVersion++,this.onNavMeshUpdate.next([this.navMeshVersion,[s,o]])}buildTile(t,s,[e,i],o=!0){const n=u&&t.buffer instanceof window.SharedArrayBuffer,r=n?t:new Float32Array(t),h=n?s:new Uint32Array(s),l={tileX:e,tileY:i,tileBoundsMin:[this.navMeshBoundsMin.x+e*this.tcs,this.navMeshBoundsMin.y,this.navMeshBoundsMin.z+i*this.tcs],tileBoundsMax:[this.navMeshBoundsMax.x+(e+1)*this.tcs,this.navMeshBoundsMax.y,this.navMeshBoundsMax.z+(i+1)*this.tcs],recastConfig:this.recastConfig,navMeshBounds:this.navMeshBounds,keepIntermediates:!1,positions:r,indices:h};if(this.workers.length>0){this.workerRoundRobin=++this.workerRoundRobin%this.workers.length;return this.workers[this.workerRoundRobin].postMessage(l,n?void 0:[r.buffer,h.buffer]),Promise.resolve()}return new Promise((t=>{requestIdleCallback((()=>{const s=this.cacheId+JSON.stringify({tileX:l.tileX,tileY:l.tileY});if(o){const e=localStorage.getItem(s);if(null!=e){const s=f(e);return this.onResult({data:{tileX:l.tileX,tileY:l.tileY,navMeshData:s}}),void t({})}}else localStorage.removeItem(s);const e=a(l);if(!e.success||!e.data)return;const i=e.data.toTypedArray();localStorage.setItem(s,M(i)),this.onResult({data:{tileX:l.tileX,tileY:l.tileY,navMeshData:i}}),t(e)}))}))}buildAllTiles(t,s){const{tileWidth:e,tileHeight:i}=this;for(let o=0;o<i;o++)for(let i=0;i<e;i++)this.buildTile(t,s,[i,o])}getTileForWorldPosition(t){return[Math.floor((t.x-this.navMeshBoundsMin.x)/this.tcs),Math.floor((t.z-this.navMeshBoundsMin.z)/this.tcs)]}getTilesForBounds(t){const s=this.getTileForWorldPosition(t.min),e=this.getTileForWorldPosition(t.max),i=[];for(let t=s[1];t<=e[1];t++)for(let o=s[0];o<=e[0];o++)i.push([o,t]);return i}destroy(){this.navMesh.destroy(),this.onNavMeshUpdate.complete();for(const t of this.workers)t.onmessage=null,c.push(t)}}const M=function(t){return btoa(String.fromCharCode(...t))},f=function(t){if(!t)return null;const s=atob(t),e=s.length,i=new Uint8Array(e);for(let t=0;t<e;t++)i[t]=s.charCodeAt(t);return i};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{init as t}from"recast-navigation";import{buildTile as e}from"./build-tile.js";let s=!1;const a=[];export function setupNavMeshWorker(){t().then((()=>{s=!0;for(const t of a)o(t)})),self.onmessage=t=>{s?o(t.data):a.push(t.data)}}const o=t=>{const s=e(t);if(!s.success||!s.data)return;const a=s.data.toTypedArray();s.data.destroy(),self.postMessage({tileX:t.tileX,tileY:t.tileY,navMeshData:a},[a.buffer])};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as e,__metadata as t}from"tslib";import{NavMeshQuery as n}from"recast-navigation";import{Vector3 as s}from"three";import{inject as r,Service as o,World as i}from"../";import u,{safeRecastInit as a}from"../actors/builtin/navmesh-actor";let h=class{constructor(){this.world=r(i),a().then((()=>{const e=this.world.actors.find((e=>e instanceof u));null!=e&&(this.navMeshActor=e,this.query=null),this.world.actorAdded.subscribe((e=>{e instanceof u&&(this.navMeshActor=e,this.query=null)})),this.world.actorRemoved.subscribe((e=>{e instanceof u&&e.id===this.navMeshActor?.id&&(this.navMeshActor=null,this.query=null)}))}))}ensureQuery(){null==this.query&&null!=this.navMeshActor&&null!=this.navMeshActor.navMesh&&(this.query=new n(this.navMeshActor.navMesh))}findPath(e,t){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),c;const n=this.findClosestPoint(e);if(null==n)return d("Start point could not be found on NavMesh",e),c;const{success:r,error:o,path:i}=this.query.computePath(n,t);return r?{success:!0,path:i.map((e=>new s(e.x,e.y,e.z)))}:(d("Failed to generate path",o),c)}findClosestPoint(e){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),null;const{success:t,point:n}=this.query.findClosestPoint(e);return t?new s(n.x,n.y,n.z):null}findRandomPoint(){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),null;const e=this.query.findRandomPoint();return{success:e.success,randomPoint:(new s).copy(e.randomPoint)}}findRandomPointAroundCircle(e,t){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),null;const n=this.query.findRandomPointAroundCircle(e,t);return{success:n.success,randomPoint:(new s).copy(n.randomPoint)}}};h=e([o(),t("design:paramtypes",[])],h);export{h as Navigation};const c={success:!1,path:[]};let l=new Set;function d(e,...t){l.has(e)||(l.add(e),setTimeout((()=>l.delete(e)),2e3),console.warn(e,...t))}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
let t=0;class i{constructor(t,i){this.state=t,this.predicate=i}}const s={loop:!0};export class AnimationState{constructor(i,n=s){this.clip=i,this.options=n,this.uuid=t++,this.transitions=[],this.options={...s,...n}}named(t){return this.name=t,this}getAncestors(){return null!=this.parent?[this,...this.parent.getAncestors()]:[this]}getRoot(){return null!=this.parent?this.parent.getRoot():this}createChild(t,i){const s=new AnimationState(t);return s.parent=this,this.transitionsTo(s,i),s}split(t,i=null,s=null){return[this.createChild(i,t),this.createChild(s,e(t))]}transitionsTo(t,s=()=>!0){this.transitions.push(new i(t,s))}transitionsOnComplete(t,i){this.transitionsTo(t,(t=>!!i&&i(t)||t>=this.clip.duration-.5))}transitionsBetween(t,i){this.transitionsTo(t,i),t.transitionsTo(this,e(i))}}export class AnimationStateMachine{constructor(t){this.initialState=t,this.timer=0,this.current=t}step(t){return this.timer+=t,this._getNext()}_getNext(t=1){const i=n(this.current.getRoot(),this.timer,this.current);return i.uuid!==this.current.uuid&&(this.timer=0,this.current=i),--t>0?this._getNext(t):this.current}}function n(t,i,s){for(const e of t.transitions)if(e.predicate(i))return n(e.state,e.state.uuid===s.uuid?i:0,s);return null==t.clip?t.getAncestors().find((t=>null!=t.clip))??t:t}const e=t=>i=>!t(i);/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{AnimationClip as o,Vector3 as t}from"three";export class RootMotionClip extends o{constructor(){super(...arguments),this.displacement=0,this.fixedInPlace=!1}static fromClip(o,e=!1,i){const n=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);if(n.fixedInPlace=e,n.rootBone=i,n.source=o,n.uuid=o.uuid,n.motionTrack=null!=i?o.tracks.find((o=>o.name===`${i.name}.position`)):o.tracks.find((o=>o.name.endsWith(".position"))),n.motionTrack){n.tracks.splice(n.tracks.indexOf(n.motionTrack),1);const o=(new t).fromArray(n.motionTrack.values,0),e=(new t).fromArray(n.motionTrack.values,n.motionTrack.values.length-3);n.displacement=e.distanceTo(o)}else console.error("Could not find root motion track",o,i);return n}static fromClipWithDistance(o,t){const e=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);return e.fixedInPlace=!0,e.source=o,e.uuid=o.uuid,e.displacement=t,e}clone(){const o=RootMotionClip.fromClip(this.source.clone(),this.fixedInPlace,this.rootBone);return o.displacement=this.displacement,o}}let e=53912381;export class BoneLayer{constructor(){this.uuid=e++,this.order=0,this.boneMask=[]}}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
package/dist/gameplay/env.js
CHANGED
package/dist/gameplay/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import"reflect-metadata";export{Container as DIContainer}from"typedi";export*from"./initiate.js";export*from"./inject.js";export{Service,Inject}from"typedi";export{ActorFactory}from"./actors/factory.js";export{Actor,BaseActor}from"./actors/actor.js";export{Component,ActorComponent,attach,Attach}from"./actors/component.js";export*from"./services/world.js";export*from"./services/render.js";export*from"./services/physics/physics-system.js";export*from"./animation/anim-sm.js";export*from"./animation/root-motion.js";export*from"./services/asset-loader.js";export*from"./services/pointer-events.js";export{VisualEffect}from"../effects/vfx/vfx-param.js";export*from"../shader/parameter.js";export*from"./ai/index.js";export*from"../effects/vfx";export*from"./services/shader-provider.js";/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -2,6 +2,7 @@ import { Constructable, ContainerInstance } from "typedi";
|
|
2
2
|
import { ShaderType, ActorType } from '../shader/shader.js';
|
3
3
|
import { World } from './services/world.js';
|
4
4
|
import { Observable } from 'rxjs';
|
5
|
+
import { DetailTier } from "../scene/model.js";
|
5
6
|
type GameClass<T> = Constructable<T>;
|
6
7
|
export type InitiateGameConfig = {
|
7
8
|
element: HTMLElement;
|
@@ -16,6 +17,11 @@ export type InitiateGameConfig = {
|
|
16
17
|
xr?: {
|
17
18
|
enabled: boolean;
|
18
19
|
};
|
20
|
+
/**
|
21
|
+
* What tier of detail to include. If Medium, then any mesh in tier High will not be loaded or rendered but it will also load
|
22
|
+
* with tier low or undefined.
|
23
|
+
*/
|
24
|
+
detailTier?: DetailTier;
|
19
25
|
rendering?: Partial<{
|
20
26
|
resolutionScale: number;
|
21
27
|
maxPixelRatio: number;
|
@@ -23,6 +29,9 @@ export type InitiateGameConfig = {
|
|
23
29
|
enabled?: boolean;
|
24
30
|
autoUpdate?: boolean;
|
25
31
|
};
|
32
|
+
bloom: {
|
33
|
+
enabled?: boolean;
|
34
|
+
};
|
26
35
|
}>;
|
27
36
|
};
|
28
37
|
export declare function initiateGame<T_Game>(gameClass: GameClass<T_Game>, config: InitiateGameConfig): HologyRuntime<T_Game>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"initiate.d.ts","sourceRoot":"","sources":["../../src/gameplay/initiate.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAa3C,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAA;
|
1
|
+
{"version":3,"file":"initiate.d.ts","sourceRoot":"","sources":["../../src/gameplay/initiate.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAa3C,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAA;AAM1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,KAAK,SAAS,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA;AAGpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,WAAW,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAA;IACvC,MAAM,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACrC,EAAE,CAAC,EAAE;QACH,OAAO,EAAE,OAAO,CAAA;KACjB,CAAC;IACF;;;MAGE;IACF,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE;YACP,OAAO,CAAC,EAAE,OAAO,CAAA;YACjB,UAAU,CAAC,EAAE,OAAO,CAAA;SACrB,CAAC;QACF,KAAK,EAAE;YACL,OAAO,CAAC,EAAE,OAAO,CAAA;SAClB,CAAA;KACF,CAAC,CAAA;CACH,CAAA;AAED,wBAAgB,YAAY,CAAC,MAAM,EACjC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,kBAAkB,GACzB,aAAa,CAAC,MAAM,CAAC,CAyJvB;AAGD,8BAAsB,YAAY;IAChC,OAAO,IAAI,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC;IAC7B,UAAU,IAAI,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC;CACjC;AAID,wBAAgB,iBAAiB,SAEhC;AAED;;;;;;GAMG;AAEH,0BAAkB,mBAAmB;IACnC,UAAU,IAAI;IACd,OAAO,IAAI;IACX,OAAO,KAAK;CACb;AAED,qBAAa,aAAa,CAAC,MAAM,GAAG,OAAO;IAYvC,OAAO,CAAC,iBAAiB;IAXpB,MAAM,EAAE,mBAAmB,CAAiC;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,UAAQ;IAClB,eAAe,EAAE,UAAU,CAAC,IAAI,CAAC,CAAsB;IAC9D,OAAO,CAAC,SAAS,CAA2B;IAC5C;;OAEG;IACH,SAAgB,KAAK,mBAA8D;gBAGzE,iBAAiB,EAAE,iBAAiB;IAE9C,QAAQ,IAAI,KAAK;IAIjB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC;IAI/C;;OAEG;IACH,QAAQ;CAyBT"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as n}from"./actors/factory.js";import{World as s}from"./services/world.js";import{SceneMaterializer as r}from"../scene/materializer.js";import{ViewController as o}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{activeContainerInstance as m}from"./actors/internal/container-map.js";import{InputService as d}from"./input/index.js";import{RuntimeAssetsService as l}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as p}from"../scene/asset-resource-loader.js";import{AssetLoader as h}from"./services/asset-loader.js";import{polyfillClient as u}from"./polyfill.js";import{Subject as f}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as g}from"../scene/runtime-bundled-backend-service.js";import{Scene as j}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";export function initiateGame(d,f){if(u(),0!=f.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(o);const
|
2
|
-
* Copyright (©)
|
1
|
+
import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as n}from"./actors/factory.js";import{World as s}from"./services/world.js";import{SceneMaterializer as r}from"../scene/materializer.js";import{ViewController as o}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{activeContainerInstance as m}from"./actors/internal/container-map.js";import{InputService as d}from"./input/index.js";import{RuntimeAssetsService as l}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as p}from"../scene/asset-resource-loader.js";import{AssetLoader as h}from"./services/asset-loader.js";import{polyfillClient as u}from"./polyfill.js";import{Subject as f}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as g}from"../scene/runtime-bundled-backend-service.js";import{Scene as j}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";export function initiateGame(d,f){if(u(),0!=f.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(o);const b=e.of("default"),y=new HologyRuntime(b),I=new n(b,{inEditor:!1});var x;e.set(n,I),x=f.element,Object.assign(x.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const D=new i(f.element,{enableXR:!0===f.xr?.enabled,maxPixelRatio:f.rendering?.maxPixelRatio,bloom:{enabled:!1!==f?.rendering?.bloom?.enabled}});D.renderer.shadowMap.enabled=f.rendering?.shadows?.enabled??!0,D.renderer.shadowMap.autoUpdate=f.rendering?.shadows?.autoUpdate??!0,null!=f?.rendering?.resolutionScale&&(D.resolutionScale=f.rendering.resolutionScale),e.set(i,D);const R=new o(D);e.set(o,R);const G=new g,z=new l(G),H=new p;H.setDataDir(f.dataDir),H.initKtx2(D.renderer);const O=Object.entries(f.shaders).map((([e,t])=>({name:e,type:t}))),P=Object.entries(f.actors).map((([e,t])=>({name:e,type:t}))),W=new v(O);e.set(v,W);const A=new h(H,z,O);e.set(h,A);const M=new j,N=new r(M,new S,z,H,D,O,P,I);e.set(r,N);const T=e.get(s);return e.set(s,T),T.materializer=N,(async()=>{const n=e.get(a);if(await n.start(),y.isShutdown)return;if(await G.preloadData(),y.isShutdown)return;T.scene=M;const{scene:s,actors:r}=await t(D,f.sceneName,f.dataDir,f.shaders,f.actors,I,G,z,H,{detailTier:f.detailTier});T.scene=s,n.scene=T.scene;for(const e of M.children)T.scene.add(e);if(y.isShutdown)return void D.stop();e.import([c]);for(const e of r)T.addActor(e);n.addFromScene(s),D.loop((e=>{})),y.status=5,m.value=b,b.remove(d),b.set({id:d,type:d});const o=b.get(d);m.value=null,y.gameInstance=o,b.get(w).start(),o instanceof GameInstance&&await o.onStart(),y._resolver(!0)})(),y}export class GameInstance{onStart(){}onShutdown(){}}export function createHologyScene(){}export class HologyRuntime{constructor(e){this.containerInstance=e,this.status=0,this.isShutdown=!1,this.shutdownStarted=new f,this.ready=new Promise((e=>{this._resolver=e}))}getWorld(){return this.containerInstance.get(s)}getService(e){return this.containerInstance.get(e)}shutdown(){this.isShutdown=!0,this.shutdownStarted.next(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(d).stop();const e=this.containerInstance.get(i);e?.stop();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(r).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
package/dist/gameplay/inject.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import t from"typedi";import{activeContainerInstance as e}from"./actors/internal/container-map.js";export function inject(n){return e.value?.get(n)??t.get(n)}export function withInjectionContext(t,n){const o=e.value;e.value=t,n(t),e.value=o}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as e}from"tslib";import{Service as t}from"typedi";import{inject as s}from"../inject.js";import{ViewController as i}from"../services/render.js";let n=class{constructor(){this.view=s(i),this.inputs=new Map,this.deltaCallbacks=new Map,this.toggleCallbacks=new Map,this.keybinds=new Map,this.mousebinds=new Map,this.touchmoveBinds=new Map,this.wheelbinds=new Map,this.onKeyDown=e=>{this.keybinds.forEach(((t,s)=>{for(const i of t)if(i.test(e))if(this.inputs.has(s))this.inputs.get(s)(!0);else if(this.toggleCallbacks.has(s)){this.toggleCallbacks.get(s)(!0);this.activeToggleCallbacks.findIndex((e=>e.keybind===i&&e.toggle===this.toggleCallbacks.get(s)))<0&&this.activeToggleCallbacks.push({keybind:i,toggle:this.toggleCallbacks.get(s)})}else console.warn("No input callback for registered for key bind "+i.display())}))},this.activeToggleCallbacks=[],this.onKeyUp=e=>{this.keybinds.forEach(((t,s)=>{for(const i of t)if(i.test(e))if(this.inputs.has(s))this.inputs.get(s)(!1);else if(this.toggleCallbacks.has(s)){this.toggleCallbacks.get(s)(!1);const e=this.activeToggleCallbacks.findIndex((e=>e.keybind===i&&e.toggle===this.toggleCallbacks.get(s)));e>=0&&this.activeToggleCallbacks.splice(e,1);for(const e of this.activeToggleCallbacks)e.toggle(!0)}else console.warn("No input callback for registered for key bind "+i.display())}))},this.onMouseMove=e=>{(null!=document.pointerLockElement||null!=document.mozPointerLockElement)&&this.mousebinds.forEach(((t,s)=>{const i=this.inputs.get(s)??this.deltaCallbacks.get(s);if(null!=i)switch(t.axis){case"x":i(e.movementX*t.multiplier);break;case"y":i(e.movementY*t.multiplier)}else console.warn("No input callback for registered for mouse bind "+t.axis)}))},this.onTouchStart=e=>{for(let t=0;t<=e.touches.length;t++){const s=e.touches[t];if(s.target instanceof HTMLCanvasElement)return void(this.prevTouchEvent=s)}e.preventDefault()},this.onTouchMove=e=>{let t=null;for(let s=0;s<=e.touches.length;s++){const i=e.touches[s];i&&i.target instanceof HTMLCanvasElement&&i.identifier===this.prevTouchEvent.identifier&&(t=i)}this.debug.innerText=t.clientX-this.prevTouchEvent.clientX+"",this.touchmoveBinds.forEach(((e,s)=>{const i=this.inputs.get(s)??this.deltaCallbacks.get(s);if(null!=i)switch(e.axis){case"x":i((t.clientX-this.prevTouchEvent.clientX)*e.multiplier);break;case"y":i((t.clientY-this.prevTouchEvent.clientY)*e.multiplier)}else console.warn("No input callback for registered for mouse bind "+e.axis)})),this.prevTouchEvent=t,e.preventDefault()},this.onTouchEnd=e=>{this.prevTouchEvent=null,e.preventDefault()},this.onWheel=e=>{this.wheelbinds.forEach(((t,s)=>{const i=this.inputs.get(s)??this.deltaCallbacks.get(s);null!=i?i(e.deltaY*t.multiplier):console.warn("No input callback for registered for wheel bind")}))},this.debug=document.createElement("div")}start(){document.addEventListener("keydown",this.onKeyDown),document.addEventListener("mousedown",this.onKeyDown),document.addEventListener("mouseup",this.onKeyUp),document.addEventListener("keyup",this.onKeyUp),document.addEventListener("mousemove",this.onMouseMove),this.view.htmlElement.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.view.htmlElement.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.view.htmlElement.addEventListener("touchend",this.onTouchEnd,{passive:!1}),document.addEventListener("wheel",this.onWheel),this.debug.style.top="40%",this.debug.style.position="absolute",this.debug.style.color="black"}stop(){document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("mousedown",this.onKeyDown),document.removeEventListener("mouseup",this.onKeyUp),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mousemove",this.onMouseMove),this.view.htmlElement.removeEventListener("touchstart",this.onTouchStart),this.view.htmlElement.removeEventListener("touchmove",this.onTouchMove),this.view.htmlElement.removeEventListener("touchend",this.onTouchEnd),document.removeEventListener("wheel",this.onWheel)}bind(e,t){this.inputs.set(e,t)}bindToggle(e,t){this.toggleCallbacks.set(e,t)}bindDelta(e,t){this.deltaCallbacks.set(e,t)}unbind(e){this.inputs.delete(e),this.toggleCallbacks.delete(e),this.deltaCallbacks.delete(e)}setKeybind(e,t){this.keybinds.has(e)||this.keybinds.set(e,[]),this.keybinds.get(e).push(t)}setMousebind(e,t){this.mousebinds.set(e,t)}setTouchMoveBind(e,t){this.touchmoveBinds.set(e,t)}setWheelbind(e,t){this.wheelbinds.set(e,t)}removeKeybind(e){this.keybinds.delete(e)}removeMousebind(e){this.mousebinds.delete(e)}removeWheelbind(e){this.wheelbinds.delete(e)}};n=e([t()],n);export{n as InputService};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{Euler as t,Vector2 as i}from"three";import{ArrayMap as s}from"../../utils/collections.js";import{clamp as o}from"../../utils/math.js";export class AxisInput{constructor(){this.vector=new i,this.togglePositiveY=t=>{this.vector.y=t?1:Math.min(this.vector.y,0)},this.toggleNegativeY=t=>{this.vector.y=t?-1:Math.max(this.vector.y,0)},this.togglePositiveX=t=>{this.vector.x=t?1:Math.min(this.vector.x,0)},this.toggleNegativeX=t=>{this.vector.x=t?-1:Math.max(this.vector.x,0)}}get horizontal(){return this.vector.x}get vertical(){return this.vector.y}}class h{constructor(){this.map=new s}emit(t){this.map.get(t).forEach((t=>t()))}add(t,i){this.map.push(t,i)}}export class ActionInput{constructor(){this.emitter=new h,this.activated=!1,this.toggle=t=>{t&&!this.activated?this.emitter.emit("start"):!t&&this.activated&&this.emitter.emit("end"),this.activated=t}}onStart(t){this.emitter.add("start",t)}onEnd(t){this.emitter.add("end",t)}}const e=2*Math.PI;export class RotationInput{constructor(){this.rotation=new t,this.rotateX=t=>{this.rotation.x=(this.rotation.x+t)%e},this.rotateY=t=>{this.rotation.y=(this.rotation.y+t)%e},this.rotateZ=t=>{this.rotation.z=(this.rotation.z+t)%e}}}export class RestrictedRotationInput extends RotationInput{constructor(i=-1/0,s=1/0,h=-1/0,e=1/0,r=-1/0,a=1/0){super(),this.minX=i,this.maxX=s,this.minY=h,this.maxY=e,this.minZ=r,this.maxZ=a,this.rotation=new t,this.rotateX=t=>{this.rotation.x=o(this.rotation.x+t,this.minX,this.maxX)},this.rotateY=t=>{this.rotation.y=o(this.rotation.y+t,this.minY,this.maxY)},this.rotateZ=t=>{this.rotation.z=o(this.rotation.z+t,this.minZ,this.maxZ)}}}export class DecimalInput{constructor(t=0,i,s){this.min=i,this.max=s,this.increment=t=>{this.value=o(this.value+t,this.min,this.max)},this.value=t}}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
const t=navigator.platform.toUpperCase().indexOf("MAC")>=0?"⌘":"Ctrl",i=["MouseLeft","MouseMiddle","MouseRight"];export class Keybind{constructor(t,i,s){this.key=t,this.shift=i,this.ctrl=s}test(t){const s=!(null!=this.shift&&"Shift"!==this.key&&this.shift!==t.shiftKey||null!=this.ctrl&&"Control"!==this.key&&this.ctrl!=t.ctrlKey);return"key"in t?t.key.toLowerCase()===this.key.toLowerCase()&&s:i[t.button]===this.key&&s}display(){return(this.shift?"⇧ + ":"")+(this.ctrl?t+" + ":"")+this.key}}export class Mousebind{constructor(t=1,i=!1,s="x"){this.sensitivity=t,this.flipped=i,this.axis=s}get multiplier(){return(this.flipped?-1:1)*this.sensitivity}}export class Wheelbind{constructor(t=1,i=!1){this.sensitivity=t,this.flipped=i}get multiplier(){return(this.flipped?-1:1)*this.sensitivity}}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export function polyfillClient(){window.requestIdleCallback=window.requestIdleCallback||function(n){const e=Date.now();return setTimeout((function(){n({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})}),1)},window.cancelIdleCallback=window.cancelIdleCallback||function(n){clearTimeout(n)}}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as e,__metadata as t}from"tslib";import{AssetResourceLoader as s}from"../../scene/asset-resource-loader.js";import{FBXLoader as r,GLTFLoader as a,MTLLoader as o,OBJLoader as i,TGALoader as n}from"three-stdlib";import{AudioLoader as d,LoadingManager as h,TextureLoader as l}from"three";import{pathJoin as u}from"../../utils/files.js";import{Service as c}from"typedi";import{materialFromAsset as g}from"../../scene/materializer.js";import{KTX2Loader as w}from"three/examples/jsm/Addons.js";import{Prefab as f}from"../../scene/objects/prefab.js";let m=class{constructor(e,t,s){this.assetResourceLoader=e,this.assetService=t,this.shaders=s,this.baseUrl="",this.urlSuffix="",this.loadingManager=new h,this.glbLoader=new a(this.loadingManager),this.fbxLoader=new r(this.loadingManager),this.objLoader=new i(this.loadingManager),this.mtlLoader=new o(this.loadingManager),this.tgaLoader=new n(this.loadingManager),this.ktx2Loader=new w(this.loadingManager),this.textureLoader=new l(this.loadingManager),this.audioLoader=new d(this.loadingManager)}resolvePath(e){return u(this.baseUrl,e)+this.urlSuffix}getAudioAtPath(e){const t=this.resolvePath(e);return this.audioLoader.loadAsync(t)}async getAudioByAssetId(e){const t=await this.assetService.getAsset(e);if(null==t)throw new Error(`No audio could be found with asset id ${e}`);return this.assetResourceLoader.getAudio(t)}async getAudioByAssetName(e){const t=await this.assetService.getAsset(e);if(null==t)throw new Error(`No audio could be found with asset name ${e}`);return this.assetResourceLoader.getAudio(t)}async getModelAtPath(e){const t=this.resolvePath(e);switch(e.split(".").pop().toLowerCase()){case"glb":case"gltf":return(await this.glbLoader.loadAsync(t)).scene;case"fbx":return this.fbxLoader.loadAsync(t);case"obj":return this.objLoader.loadAsync(t);default:throw new Error(`File suffix is not supperted in file ${e}`)}}async getGltfAtPath(e){const t=this.resolvePath(e);return this.glbLoader.loadAsync(t)}async getModelByAssetName(e){const t=(await this.assetService.getAssets()).find((t=>t.name===e));if(null==t)throw new Error(`No model could be found with asset name ${e}`);return this.assetResourceLoader.getMesh(t)}async getModelByAssetId(e){const t=await this.assetService.getAsset(e);if(null==t)throw new Error(`No model could be found with asset id ${e}`);return this.assetResourceLoader.getMesh(t)}async getTextureByAssetName(e){const t=(await this.assetService.getAssets()).find((t=>t.name===e));if(null==t)throw new Error(`No texture could be found with asset name ${e}`);return this.assetResourceLoader.getTexture(t)}async getTextureByAssetId(e){const t=await this.assetService.getAsset(e);if(null==t)throw new Error(`No texture could be found with asset id ${e}`);return this.assetResourceLoader.getTexture(t)}async getMaterialByAssetId(e){const t=await this.assetService.getAsset(e);if(null==t)throw new Error(`No material could be found with asset id ${e}`);return g(t,null,this.assetService,this.assetResourceLoader,this.shaders,!1)}async getAsset(e){return this.assetService.getAsset(e)}async getPrefabByName(e){const t=(await this.assetService.getAssets()).find((t=>t.name===e));if("prefab"!==t.type)throw`Asset with name ${e} is not a prefab`;return new f(t)}async getPrefabById(e){const t=await this.getAsset(e);if("prefab"!==t.type)throw`Asset with name ${name} is not a prefab`;return new f(t)}};m=e([c(),t("design:paramtypes",[s,Object,Array])],m);export{m as AssetLoader};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as t,__metadata as e}from"tslib";import*as s from"@dimforge/rapier3d-compat";import{QueryFilterFlags as i}from"@dimforge/rapier3d-compat";import{BehaviorSubject as o,distinctUntilChanged as n,filter as r,map as a,Subject as l,takeUntil as c}from"rxjs";import*as d from"three";import{ArrowHelper as h,BufferAttribute as y,BufferGeometry as u,Group as p,LineSegments as g,Matrix4 as m,Object3D as f,Quaternion as w,Raycaster as x,Scene as b,Vector3 as B}from"three";import{Service as v}from"typedi";import{AssetMeshInstance as C}from"../../../scene/asset-resource-loader.js";import{BoxCollisionShape as z,CapsuleCollisionShape as A,CollisionShapeSource as S,ConeCollisionShape as D,ConvexPolyhedronCollisionShape as R,CylinderCollisionShape as T,PhysicalShapeMesh as M,PlaneCollisionShape as E,SphereCollisionShape as P,TrimeshCollisionShape as V}from"../../../index.js";import{LandscapeGroup as _}from"../../../scene/landscape/landscape.js";import{ViewController as F}from"../render.js";import{World as k}from"../world.js";import*as I from"three/examples/jsm/utils/BufferGeometryUtils.js";import{calculateEffectiveScale as W}from"../../../utils/three/traverse.js";import{AbstractPhysicsSystem as j}from"./abstract-physics-system.js";import{ActorComponent as L,Component as N}from"../../../gameplay/actors/component.js";import{inject as O}from"../../../gameplay/inject.js";export{Component,ActorComponent,attach,Attach}from"../../actors/component.js";export class RayTestResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.hitNormal=new B}}export class ShapeCastResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.normal=new B}reset(){this.actor=void 0,this.hasHit=!1,this.distance=0,this.hitPoint.set(0,0,0),this.normal.set(0,0,0)}}ShapeCastResult.shared=new ShapeCastResult;export var PhysicsBodyType;!function(t){t[t.dynamic=1]="dynamic",t[t.static=2]="static",t[t.kinematic=4]="kinematic",t[t.kinematicVelocityBased=8]="kinematicVelocityBased"}(PhysicsBodyType||(PhysicsBodyType={}));const G=new B,q=new B,U=new w,H=new w,K=(new w,[]);let Q=class extends j{set showDebug(t){this.shouldRenderDebug=t,this.debugMesh&&(this.debugMesh.visible=t)}get showDebug(){return this.shouldRenderDebug}constructor(t){super(),this.viewController=t,this.staticMeshes=new Map,this.staticBodies=new Map,this.actorBodies=new Map,this.bodyActors=new Map,this.collisionEvents=new l,this.beforeStep=new l,this.afterStep=new l,this.shouldRenderDebug=!1,this.shapeCacheBox=new Map,this.shapeCacheBall=new Map,this._raycaster=new x,this._reusableResult=new RayTestResult,this._raytestDiff=new B,this._raytestDirection=new B,this.controlledActors=new Set,this.ready=this.setup()}getBallShape(t){let e=this.shapeCacheBall.get(t);return null==e&&(e=new s.Ball(t),this.shapeCacheBall.set(t,e)),e}getBoxShape(t,e,i){const o=t+1e6*e+1e12*i;let n=this.shapeCacheBox.get(o);return null==n&&(n=new s.Cuboid(t,e,i),this.shapeCacheBox.set(o,n)),n}hasBoxIntersection(t){const e=t.getCenter(G),s=t.getSize(q),i=this.getBoxShape(s.x/2,s.y/2,s.z/2);return null!=this.world.intersectionWithShape(e,U,i)}hasSphereIntersection(t){const e=this.getBallShape(t.radius);return null!=this.world.intersectionWithShape(t.center,U,e)}createDebugMesh(){return new g(new u,new d.LineBasicMaterial({color:255}))}async start(){return await this.ready,this.handleTick(),this.ready}renderDebug(){if(null==this.scene)return;null==this.debugMesh&&(this.debugMesh=this.createDebugMesh(),this.debugMesh.visible=this.shouldRenderDebug,this.debugMesh.raycast=function(){},this.scene?.add(this.debugMesh));const t=this.world.debugRender();this.debugMesh.geometry.setAttribute("position",new y(t.vertices,3))}async setup(){if(null!=this.rapier)throw new Error("Rapier is already estup");this.rapier=await rt(),this.eventQueue=new s.EventQueue(!0),this.setupWorld()}handleTick(){this.fixedupdateSub=this.viewController.onUpdate().subscribe((t=>{t=Math.min(.1,t),this.beforeStep.next(t),this.updatePhysics(t),this.showDebug&&this.renderDebug(),this.world.bodies.forEach((t=>{if(t.isFixed())return;const e=this.staticMeshes.get(t)??this.bodyActors.get(t)?.object;null!=e&&e.parent instanceof b&&(ct(e.position,t.translation()),(t.isDynamic()||t.isKinematic()&&!this.controlledActors.has(this.bodyActors.get(t)?.id))&&dt(e.quaternion,t.rotation()),e.updateMatrix(),e.updateWorldMatrix(!1,!1))})),this.afterStep.next(t)}))}_updateWorld(){this.world.timestep=0,this.world.step()}updatePhysics(t){this.world.timestep=t,this.world.step(this.eventQueue),this.eventQueue.drainCollisionEvents(((t,e,s)=>{this.collisionEvents.next({handle1:t,handle2:e,started:s}),this.collisionEvents.next({handle1:e,handle2:t,started:s})}))}rayTestFromCamera(t,e,s){this._raycaster.setFromCamera(it,this.viewController.getCamera());const i=this._raycaster.ray.origin,o=this._raycaster.ray.direction.multiplyScalar(t).add(i);return this.rayTest(i,o,e,s)}rayTest(t,e,s,i){null==s&&(s=this._reusableResult);const o=this._raytestDiff,n=this._raytestDirection;if(o.subVectors(e,t),n.copy(o).normalize(),0===n.length())return console.warn("Ray test called with to and from being equal"),s;at(mt.origin,t),at(mt.dir,n);const r=o.length(),a=this.world.castRayAndGetNormal(mt,r,!1,void 0,i?.collisionFilter,void 0,null!=i?.excludeActor?this.actorBodies.get(i.excludeActor.id):void 0,i?.excludeTriggers?t=>!t.isSensor():void 0);if(s.hasHit=null!=a,s.hasHit){const e=mt.pointAt(a.timeOfImpact);s._internal=a,ct(s.hitNormal,a.normal),ct(s.hitPoint,e),s.distance=yt.subVectors(s.hitPoint,t).length();const i=this.world.bodies.getAll().find((t=>function(t,e){for(let s=0,i=t.numColliders();s<i;s++){const i=t.collider(s);if(e(i))return i}}(t,(t=>t===a.collider))));s.actor=null!=i?this.bodyActors.get(i):null}if(this.showDebug){let e;K.length>0?(e=K.pop(),e.setDirection(n),e.position.copy(t),e.setLength(r,.2,.1),e.setColor(i?.debugColor??255)):e=new h(n,t,r,i?.debugColor??255),this.scene?.add(e),setTimeout((()=>{this.scene?.remove(e),K.push(e)}),i?.debugLifetime??200)}return s}setGravity(t,e,s){this.world.gravity.x=t,this.world.gravity.y=e,this.world.gravity.z=s}getGravity(){return J.set(this.world.gravity.x,this.world.gravity.y,this.world.gravity.z)}addFromScene(t){this.addRecursively(t);for(const t of this.staticBodies.values())ht(t,(t=>t.setActiveEvents(s.ActiveEvents.COLLISION_EVENTS)))}addRecursively(t){if(this.removeSceneObject(t),!function(t){if(null!=t.userData?.src){const e=t.userData?.src;return"actor"===e.type}return!1}(t))if(t instanceof M&&null!=t.collisionShape){const e=this.createStaticBody(t,[t.collisionShape],t.physics);this.staticMeshes.set(e,t),this.staticBodies.set(t,e)}else if(t instanceof C&&!1!==t.userData?.src?.collisionDetection)if(t.children[0]&&t.children[0].instanceMatrix)this.createForInstancedMesh(t.children[0],t.collisionShapes);else{const e=this.createStaticBody(t,t.collisionShapes,t.physics);this.staticMeshes.set(e,t),this.staticBodies.set(t,e)}else t instanceof _?this.addLandscapeGroup(t):(t instanceof p||t instanceof b)&&t.children.forEach((t=>this.addRecursively(t)))}createForInstancedMesh(t,e){const s=new m,i=e.filter((t=>null!=t)).map((t=>t.source===S.rendered?t.withOffset(wt):t));for(let e=0;e<t.count;e++){if(null!=t.userData.hasCollision&&!t.userData.hasCollision[e])continue;const o=new f;o.matrix.identity(),s.fromArray(t.instanceMatrix.array,16*e),o.applyMatrix4(s);this.createStaticBody(o,i)}}getCharacterController(t){return this.world?.createCharacterController(t)}getActorComputedMovement(t,e,s,o=null){const n=this.actorBodies.get(t.id);this.controlledActors.add(t.id);const r=n.collider(0);e.computeColliderMovement(r,s,i.EXCLUDE_SENSORS,o,pt);const a=e.computedMovement();return ct(ut,a),ut}createCollider(t,e){const s=this.addShape(e?.body,t);return new PhysicsCollider(s,this.world)}createBody(t=PhysicsBodyType.dynamic,e={}){const i=(()=>{switch(t){case PhysicsBodyType.dynamic:return s.RigidBodyDesc.dynamic();case PhysicsBodyType.static:return s.RigidBodyDesc.fixed();case PhysicsBodyType.kinematic:return s.RigidBodyDesc.kinematicPositionBased();case PhysicsBodyType.kinematicVelocityBased:return s.RigidBodyDesc.kinematicVelocityBased();default:return s.RigidBodyDesc.dynamic()}})();e.position&&i.setTranslation(e.position.x,e.position.y,e.position.z),e.rotation&&i.setRotation({x:e.rotation.x,y:e.rotation.y,z:e.rotation.z,w:e.rotation.w}),"boolean"==typeof e.canSleep&&i.setCanSleep(e.canSleep),"boolean"==typeof e.ccdEnabled&&i.setCcdEnabled(e.ccdEnabled),"number"==typeof e.gravityScale&&i.setGravityScale(e.gravityScale),"number"==typeof e.mass&&i.setAdditionalMass(e.mass),void 0!==e.userData&&(i.userData=e.userData);const o=this.world.createRigidBody(i);return new PhysicsBody(o,this.world)}getCharacterComputedMovement(t,e,s,o=null){const n=t.collider;e.computeColliderMovement(n,s,i.EXCLUDE_SENSORS,o,pt);const r=e.computedMovement();return ct(ut,r),ut}setNextKinematicTranslation(t,e){const s=this.actorBodies.get(t.id),i=s.translation();i.x+=e.x,i.y+=e.y,i.z+=e.z,s?.setNextKinematicTranslation(i)}setAngularVelocity(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.setAngvel(tt,!0)}setLinearVelocity(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.setLinvel(tt,!0)}getLinearVelocity(t,e=new B){const s=this.actorBodies.get(t.id).linvel();return e.x=s.x,e.y=s.y,e.z=s.z,e}getAngularVelocity(t,e=new B){const s=this.actorBodies.get(t.id).angvel();return e.x=s.x,e.y=s.y,e.z=s.z,e}setLinearDamping(t,e){const s=this.actorBodies.get(t.id);s?.setLinearDamping(e)}setAngularDamping(t,e){const s=this.actorBodies.get(t.id);s?.setAngularDamping(e)}setPosition(t,e){const s=this.actorBodies.get(t.id);s?.setTranslation(ot(e),!1)}getPosition(t,e=new B){const s=this.actorBodies.get(t.id);s&&ct(e,s.translation())}setRotation(t,e){const s=this.actorBodies.get(t.id);s?.setTranslation(nt(e),!1)}getRotation(t,e=new w){const s=this.actorBodies.get(t.id);s&&dt(e,s.rotation())}lockTranslations(t,e){const s=this.actorBodies.get(t.id);s?.lockTranslations(e,!1)}lockRotations(t,e){const s=this.actorBodies.get(t.id);s?.lockRotations(e,!1)}setEnabledTranslations(t,e,s,i){const o=this.actorBodies.get(t.id);o?.setEnabledTranslations(e,s,i,!1)}setEnabledRotations(t,e,s,i){const o=this.actorBodies.get(t.id);o?.setEnabledRotations(e,s,i,!1)}addLandscapeGroup(t){const e=t.userData.src,i=e.landscape.heightMaps;for(const n of t.sections){this.staticBodies.has(n)&&this.world.removeRigidBody(this.staticBodies.get(n));var o=n.getWorldPosition(new B);if(e.landscape.holes&&e.landscape.holes.some((t=>t.m===n.name&&0!==t.w[0]))){const t=n.geometry.clone(),i=n.scale,r=n.geometry.getAttribute("hole"),a=new Float32Array(t.getAttribute("position").array);for(let t=0;t<a.length;t+=3)a[t]*=i.x,a[t+1]*=i.y,a[t+2]*=i.z;const l=t.index;for(let t=0;t<l.count;t+=3){const e=r.getX(l.getX(t)),s=r.getX(l.getY(t)),i=r.getX(l.getZ(t));(e>.5||s>.5||i>.5)&&(l.setX(t,0),l.setY(t,0),l.setZ(t,0))}const c=s.ColliderDesc.trimesh(a,new Uint32Array(t.getIndex().array));if(!1!==e.collisionDetection){const t=this.world.createRigidBody(s.RigidBodyDesc.fixed()),e=new s.Vector3(0,0,0);at(e,o),t.setTranslation(e,!1),this.world.createCollider(c,t),this.staticBodies.set(n,t)}continue}const t=e.landscape.options.density+1,r=e.landscape.options.sectionSize,a=new Array(t);for(let e=0;e<t;e++)a[e]=new Array(t).fill(0);const l=i.find((t=>t.x===n.x&&t.y==n.y));if(null!=l)for(const e of l.points){if(null==a[e.i%t])continue;const s=t-1-Math.floor(e.i/t);s in a[e.i%t]?a[e.i%t][s]=e.y/r:console.warn("wrong index",{points:a,point:e,i:e.i%t,k:s,heightMap:l})}const c=e.landscape.options.density,d=a.flatMap((t=>t.reverse())),h=s.ColliderDesc.heightfield(c,c,new Float32Array(d),new s.Vector3(r,r,r));if(!1!==e.collisionDetection){const t=this.world.createRigidBody(s.RigidBodyDesc.fixed()),e=new s.Vector3(0,0,0);at(e,o),t.setTranslation(e,!1),this.world.createCollider(h,t),this.staticBodies.set(n,t)}}}setEnabled(t,e){const s=this.actorBodies.get(t.id);s?.setEnabled(e)}addActor(t,e,i={}){if(0==e.length)return void console.error("No collision shapes were defined when adding actor to the physics system.");this.removeActor(t);const o=t.object;let n;switch(i.type??PhysicsBodyType.static){case PhysicsBodyType.dynamic:n=s.RigidBodyDesc.dynamic(),n.mass=i.mass??1;break;case PhysicsBodyType.kinematic:n=s.RigidBodyDesc.kinematicPositionBased();break;case PhysicsBodyType.kinematicVelocityBased:n=s.RigidBodyDesc.kinematicVelocityBased();break;default:n=i.isTrigger?s.RigidBodyDesc.kinematicVelocityBased():s.RigidBodyDesc.fixed()}const r=this.world.createRigidBody(n);r.enableCcd(1==i.continousCollisionDetection);for(const t of e)this.addShape(r,t,o);ht(r,(t=>{null!=i.isTrigger&&(t.setSensor(i.isTrigger),t.setActiveCollisionTypes(s.ActiveCollisionTypes.ALL),t.setActiveEvents(s.ActiveEvents.COLLISION_EVENTS)),null!=i.friction&&t.setFriction(i.friction),null!=i.density&&t.setDensity(i.density),null!=i.mass&&t.setMass(i.mass),null!=i.restitution&&t.setRestitution(i.restitution)})),Z(r,o),!0===i.ignoreForNavMesh&&(r.userData={ignoreForNavMesh:!0}),this.actorBodies.set(t.id,r),this.bodyActors.set(r,t)}applyTorque(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.addTorque(tt,!0)}applyTorqueImpulse(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.applyTorqueImpulse(tt,!0)}resetForces(t){const e=this.actorBodies.get(t.id);e?.resetForces(!1)}resetTorques(t){const e=this.actorBodies.get(t.id);e?.resetTorques(!1)}applyForce(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.addForce(tt,!0)}applyImpulse(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.applyImpulse(tt,!0)}applyLocalForce(t,e,s){const i=this.actorBodies.get(t.id);at(tt,e),null==s?i?.addForce(tt,!0):(at(et,s),i?.addForceAtPoint(tt,et,!0))}applyLocalImpulse(t,e,s){const i=this.actorBodies.get(t.id);at(tt,e),null==s?i.applyImpulse(tt,!0):(at(et,s),i.applyImpulseAtPoint(tt,et,!0))}applyRadiusImpulse(t,e,i){this.world.bodies.forEach((o=>{if(o.collider(0)?.isSensor())return;if(o.bodyType()!==s.RigidBodyType.Dynamic)return;const n=st;ct(n,o.translation());const r=n.clone().sub(t);if(r.length()>e)return;const a=r.clone().normalize().multiplyScalar(i);tt.x=a.x,tt.y=a.y,tt.z=a.z,o.applyImpulse(tt,!0)}))}removeActor(t){if(null==t)return;this.controlledActors.delete(t.id);const e=this.actorBodies.get(t.id);null!=e&&(this.bodyActors.delete(e),this.world.removeRigidBody(e)),this.actorBodies.delete(t.id)}removeRemoved(t){if(null==t)return;const e=new Set;t.traverse((t=>{e.add(t.uuid)}));for(const[t,s]of this.staticBodies.entries())!e.has(t.uuid)&&this.world.getRigidBody(s.handle)&&(this.staticBodies.delete(t),this.world.removeRigidBody(s))}removeSceneObject(t){if(t instanceof _){for(const e of t.sections)this.removeSceneObject(e);return}let e=this.staticBodies.get(t);null!=e&&this.world.getRigidBody(e.handle)&&this.world.removeRigidBody(e),this.staticBodies.delete(t)}activateActorEvents(t){this.actorBodies.get(t.id)}_onCollisionWithActorEvent(t,e,s){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((({started:t})=>t===s)),a((({handle1:t,handle2:e,started:s})=>({a1:this.bodyActors.get(this.world.getCollider(t)?.parent()),a2:this.bodyActors.get(this.world.getCollider(e)?.parent()),started:s}))),r((({a1:s,a2:i})=>null!=s&&null!=i&&s.id===t.id&&e(s,i))),a((({a2:t})=>t)))}onBeginContact(t){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((t=>t.started)),r((({handle1:e})=>{const s=this.bodyActors.get(this.world.getCollider(e)?.parent());return null!=s&&s.id===t.id})),a((t=>t.handle2)))}onEndContact(t){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((t=>!t.started)),r((({handle1:e})=>{const s=this.bodyActors.get(this.world.getCollider(e)?.parent());return null!=s&&s.id===t.id})),a((t=>t.handle2)))}onHasContactChanged(t){const e=new Set,s=new o(!1);return this.onBeginContact(t).subscribe((t=>{e.add(t),s.next(e.size>0)})),this.onEndContact(t).subscribe((t=>{e.delete(t),s.next(e.size>0)})),s.pipe(n())}onBeginOverlapWithActorType(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>s instanceof e),!0)}onEndOverlapWithActorType(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>s instanceof e),!1)}onBeginOverlapWithActor(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>e.id===s.id),!0)}onEndOverlapWithActor(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>e.id===s.id),!1)}onCollisionWithActor(t,e){return this.onBeginOverlapWithActor(t,e)}onCollisionWithActorType(t,e){return this.onBeginOverlapWithActorType(t,e)}updateActorTransform(t){const e=this.actorBodies.get(t.id);null!=e?Z(e,t.object):console.warn("Actor has not been added to physics world",t)}setupWorld(){const t=new s.World({x:0,y:-9.81,z:0});this.world=t}sphereCast(t,e,s,i,o=ShapeCastResult.shared,n=void 0){o.reset();const r=this.getBallShape(e);this.shapeCacheBall.get;const a={x:t.x,y:t.y,z:t.z},l={x:s.x,y:s.y,z:s.z},c=this.world.castShape(a,{x:0,y:0,z:0,w:1},l,r,.01,i,!0,null,n,null,void 0,void 0);if(null!=c){ct(o.hitPoint,c.witness1),o.normal.set(c.normal1.x,c.normal1.y,c.normal1.z),o.distance=c.time_of_impact,o.hasHit=!0;const t=c.collider.parent();if(t){const e=this.bodyActors.get(t);e&&(o.actor=e)}}return o}castActorShape(t,e,s,i=ShapeCastResult.shared,o=void 0){i.reset();const n=this.actorBodies.get(t.id);if(n&&n.numColliders()>0){for(let t=0;t<n.numColliders();t++){const r=n.collider(t);let a=r.shape,l=r.translation(),c=r.rotation(),d=e,h=s;const y=this.world.castShape(l,c,d,a,.01,h,!0,null,o,null,n,void 0);if(null!=y){y.collider;const t=r;return ct(i.hitPoint,y.witness1),xt(t.rotation(),y.normal1,i.normal,H),i.distance=y.time_of_impact,i.actor=this.bodyActors.get(y.collider.parent()),i.hasHit=!0,i}}return i}return console.warn("Actor is not added to the physics system"),i}stop(){this.world?.bodies.forEach((t=>this.world.removeRigidBody(t))),this.world?.free(),this.fixedupdateSub?.unsubscribe(),K.length=0}createStaticBody(t,e,i){const o=i?.type===PhysicsBodyType.dynamic?s.RigidBodyDesc.dynamic():s.RigidBodyDesc.fixed(),n=this.world.createRigidBody(o);for(const s of e){if(null==s){console.warn("Collision shape is missing for object",t);continue}const o=this.addShape(n,s,t);null!=i?.friction&&o.setFriction(i.friction),null!=i?.density&&o.setDensity(i.density),null!=i?.mass&&o.setMass(i.mass/e.length),null!=i?.restitution&&o.setRestitution(i.restitution)}return Z(n,t),n.userData=t.uuid,n}addShape(t=void 0,e,s){const i=s?.getWorldScale(gt)??$,o=this.createShape(e,i);this.applyShapeSettings(o,e);const n=e.offset.clone().multiply(i);at(o.translation,n);const r=(new w).setFromEuler(e.rotation);e instanceof R&&e.mesh instanceof d.Mesh&&r.multiply(e.mesh.getWorldQuaternion(Y)),lt(o.rotation,r);return this.world.createCollider(o,t)}applyShapeSettings(t,e){null!=e.collisionGroup&&t.setCollisionGroups(e.collisionGroup),t.friction=e.friction??.1,null!=e.restitution&&(t.restitution=e.restitution),null!=e.density&&(t.density=e.density,t.massPropsMode=s.MassPropsMode.Density),null!=e.mass&&(t.mass=e.mass,t.massPropsMode=s.MassPropsMode.Mass)}createShape(t,e){if(t instanceof z)return s.ColliderDesc.cuboid(t.dimensions.x*e.x/2,t.dimensions.y*e.y/2,t.dimensions.z*e.z/2);if(t instanceof A){return s.ColliderDesc.capsule(t.length/2*e.y,t.radius*Math.max(e.z,e.x))}if(t instanceof V){const i=null!=t.geometry.getIndex()?t.geometry:I.mergeVertices(t.geometry),o=extractFloat32Array(i.getAttribute("position"));for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z;return s.ColliderDesc.trimesh(o,new Uint32Array(i.getIndex().array))}if(t instanceof R){let i;t.mesh instanceof d.Mesh?i=t.mesh.geometry:t.mesh instanceof d.BufferGeometry?i=t.mesh:console.log("Unknownd shape",{shapeInfo:t});const o=extractFloat32Array(i.getAttribute("position"));if(t.mesh instanceof d.Mesh){const e=W(t.mesh);for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z}for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z;const n=o;n.length;return s.ColliderDesc.convexHull(n)}if(t instanceof P){const i=2*e.x-e.y-e.z;return Math.abs(i)>.01?this.createShape(new R(new d.SphereGeometry(t.radius).scale(e.x,e.y,e.z)),new B(1,1,1)):s.ColliderDesc.ball(t.radius*Math.max(e.x,e.y,e.z))}return t instanceof T?s.ColliderDesc.cylinder(t.height/2*e.y,t.radiusTop*Math.max(e.z,e.x)):t instanceof D?s.ColliderDesc.cone(t.height*e.y,t.radiusBottom/2*Math.max(e.z,e.x)):t instanceof E?s.ColliderDesc.cuboid(t.width/2*e.x,t.height/2*e.y,.001):(console.error("Unsupported shape",t),s.ColliderDesc.cuboid(1,1,1))}createCharacterCollision(){return new s.CharacterCollision}};Q=t([v(),e("design:paramtypes",[F])],Q);export{Q as PhysicsSystem};const X=new B,Y=new d.Quaternion;function Z(t,e){const s=e.getWorldPosition(X),i=e.getWorldQuaternion(Y);t.setTranslation(ot(s),!1),t.setRotation(nt(i),!1)}const J=new B,$=new B(1,1,1),tt=new s.Vector3(0,0,0),et=new s.Vector3(0,0,0),st=new B,it=new d.Vector2;function ot(t){return at(tt,t),tt}function nt(t){return lt(H,t),H}const rt=async()=>{let t=await import("@dimforge/rapier3d-compat");return await t.init(),t};function at(t,e){t.x=e.x,t.y=e.y,t.z=e.z}function lt(t,e){t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w}function ct(t,e){t.x=e.x,t.y=e.y,t.z=e.z}function dt(t,e){t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w}function ht(t,e){for(let s=0,i=t.numColliders();s<i;s++){e(t.collider(s))}}const yt=new B,ut=new B,pt=t=>!t.isSensor(),gt=new B;const mt=new s.Ray(new s.Vector3(0,0,0),new s.Vector3(0,1,0));let ft=class extends L{constructor(){super(...arguments),this._active=!0,this.physics=O(Q),this.world=O(k)}set active(t){this._active=t,t?(this.world.scene.remove(this.actor.object),this.physics.setEnabled(this.actor,t)):(this.world.scene.add(this.actor.object),this.physics.setEnabled(this.actor,t))}get active(){return this._active}};ft=t([N()],ft);export function extractFloat32Array(t){const e=t.itemSize,s=t.count,i=new Float32Array(s*e);for(let o=0;o<s;o++)for(let s=0;s<e;s++)i[o*e+s]=t.getComponent(o,s);return i}const wt=new B;function xt(t,e,s,i){return i.set(t.x,t.y,t.z,t.w),s.set(e.x,e.y,e.z),s.applyQuaternion(i),s}export class PhysicsCollider{constructor(t,e){this.collider=t,this.world=e}dispose(){this.world.removeCollider(this.collider,!1)}set mass(t){this.collider.setMass(t)}get mass(){return this.collider.mass()}set friction(t){this.collider.setFriction(t)}get friction(){return this.collider.friction()}set restitution(t){this.collider.setRestitution(t)}get restitution(){return this.collider.restitution()}set density(t){this.collider.setDensity(t)}get density(){return this.collider.density()}set isTrigger(t){this.collider.setSensor(t)}get isTrigger(){return this.collider.isSensor()}set collisionGroups(t){this.collider.setCollisionGroups(t)}get collisionGroups(){return this.collider.collisionGroups()}set enabled(t){this.collider.setEnabled(t)}get enabled(){return this.collider.isEnabled()}}export class PhysicsBody{constructor(t,e){this.body=t,this.world=e}dispose(){this.world.removeRigidBody(this.body)}setEnabled(t){this.body.setEnabled(t)}isEnabled(){return this.body.isEnabled()}getPosition(t){const e=this.body.translation();return t.set(e.x,e.y,e.z),t}setPosition(t){this.body.setTranslation({x:t.x,y:t.y,z:t.z},!0)}getRotation(t){const e=this.body.rotation();return t.set(e.x,e.y,e.z,e.w),t}setRotation(t){this.body.setRotation({x:t.x,y:t.y,z:t.z,w:t.w},!0)}getLinearVelocity(t){const e=this.body.linvel();return t.set(e.x,e.y,e.z),t}setLinearVelocity(t){this.body.setLinvel({x:t.x,y:t.y,z:t.z},!0)}getAngularVelocity(t){const e=this.body.angvel();return t.set(e.x,e.y,e.z),t}setAngularVelocity(t){this.body.setAngvel({x:t.x,y:t.y,z:t.z},!0)}applyImpulse(t,e=!0){this.body.applyImpulse({x:t.x,y:t.y,z:t.z},e)}applyTorqueImpulse(t,e=!0){this.body.applyTorqueImpulse({x:t.x,y:t.y,z:t.z},e)}setNextKinematicTranslation(t){this.body.setNextKinematicTranslation({x:t.x,y:t.y,z:t.z})}setNextKinematicRotation(t){this.body.setNextKinematicRotation({x:t.x,y:t.y,z:t.z,w:t.w})}isDynamic(){return this.body.isDynamic()}isKinematic(){return this.body.isKinematic()}isStatic(){return this.body.isFixed()}sleep(){this.body.sleep()}wakeUp(){this.body.wakeUp()}}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as t,__metadata as e}from"tslib";import{Raycaster as i,Vector2 as o}from"three";import{Service as n}from"typedi";import{ViewController as s}from"./render";import{World as r}from"./world";import{inject as c}from"../../gameplay";import{Subject as h,tap as p,map as a,filter as d,takeUntil as l,withLatestFrom as b,mergeMap as P,merge as u,from as j}from"rxjs";let w=class{constructor(){this.view=c(s),this.world=c(r),this.enabled=!1,this.stopped=new h,this.monitoredObjects=new Map,this.useCache=!1,this.cachePointerPosition=new o,this.pointerPosition=new o,this.adjustedPosition=new o,this.raycastIntersectionResult=[],this.raycaster=new i,this.onClick=new h,this.onDoubleClick=new h,this.onPointerMove=new h,this.onPointerDown=new h,this.onPointerUp=new h,this.onPointerEnterObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),p((t=>{null==t&&(e=!1)})),d((t=>null!=t&&!e)),p((()=>{e=!0})),a((e=>({intersection:e,object:t}))))},this.onPointerEnterActor=t=>this.onPointerEnterObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerEnterActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerEnterActor(t)))),this.onPointerLeaveObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),p((t=>{null!=t&&(e=!1)})),d((t=>null==t&&!e)),p((()=>{e=!0})),a((e=>({intersection:e,object:t}))))},this.onPointerLeaveActor=t=>this.onPointerLeaveObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerLeaveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerLeaveActor(t)))),this.onClickObject3D=t=>{const e=this.onPointerDown.pipe(a((()=>this.findIntersection(t))));return this.onPointerUp.pipe(a((()=>this.findIntersection(t)))).pipe(this.tapMonitorObject(t),b(e),d((([t,e])=>null!=t&&null!=e)),a((([e])=>({intersection:e,object:t}))))},this.onClickActor=t=>this.onClickObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onClickActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onClickActor(t)))),this.onPointerDownActor=t=>this.onPointerDownObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerDownActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerDownActor(t)))),this.onPointerDownObject3D=t=>this.onPointerDown.pipe(this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.onPointerUpActor=t=>this.onPointerUpObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerUpActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerUpActor(t)))),this.onPointerUpObject3D=t=>this.onPointerUp.pipe(this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.onPointerMoveActor=t=>this.onPointerMoveObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerMoveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerMoveActor(t)))),this.onPointerMoveObject3D=t=>this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.usingPointerMoveEvents=!1,this.handlers={click:t=>{this.onClick.next(t)},dblclick:t=>{this.onDoubleClick.next(t)},pointermove:t=>{this.onPointerMove.next(t)},pointerup:t=>{this.onPointerUp.next(t)},pointerdown:t=>{this.onPointerDown.next(t)}},this.raycaster.firstHitOnly=!0}start(){this.enabled||(this.enabled=!0,Object.entries(this.handlers).forEach((([t,e])=>{this.view.htmlElement.addEventListener(t,(i=>{("pointermove"!==t||this.usingPointerMoveEvents)&&(this.updateRaycast(i),e(i))}))})),this.view.onLateUpdate().pipe(l(this.stopped)).subscribe((()=>this.useCache=!1)))}stop(){this.enabled=!1,Object.entries(this.handlers).forEach((([t,e])=>{document.removeEventListener(t,e)})),this.stopped.next(!0),this.onClick.complete(),this.onDoubleClick.complete(),this.onPointerMove.complete(),this.onPointerDown.complete(),this.onPointerUp.complete()}addMonitoredObject(t){const e=this.monitoredObjects.get(t)??0;this.monitoredObjects.set(t,e+1)}removeMonitoriedObject(t){const e=this.monitoredObjects.get(t);null!=e&&(e>1?this.monitoredObjects.set(t,e-1):this.monitoredObjects.delete(t))}updateRaycast(t){this.pointerPosition.set(t.x,t.y),this.useCache&&this.cachePointerPosition.equals(this.pointerPosition)||(this.cachePointerPosition.copy(this.pointerPosition),this.useCache=!0,this.adjustedPosition.x=t.offsetX/this.view.htmlElement.offsetWidth*2-1,this.adjustedPosition.y=-t.offsetY/this.view.htmlElement.offsetHeight*2+1,this.raycaster.setFromCamera(this.adjustedPosition,this.view.getCamera()),this.raycastIntersectionResult.length=0,this.raycaster.intersectObject(this.world.scene,!0,this.raycastIntersectionResult))}tapUsingPointerMove(){return p({subscribe:()=>{this.usingPointerMoveEvents=!0},unsubscribe:()=>{}})}tapMonitorObject(t){return p({subscribe:()=>{this.addMonitoredObject(t)},unsubscribe:()=>{this.removeMonitoriedObject(t)}})}findIntersection(t){if(this.raycastIntersectionResult.length>0){let e=this.raycastIntersectionResult[0].object;for(;null!=e;){if(e.uuid===t.uuid)return this.raycastIntersectionResult[0];e=e.parent}}return null}};w=t([n(),e("design:paramtypes",[])],w);export{w as PointerEvents};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as e,__metadata as t}from"tslib";import{Service as i}from"typedi";import{Camera as s}from"three";import{RenderingView as r}from"../../rendering.js";import{Subject as o,takeUntil as n}from"rxjs";import*as a from"three";let h=class{constructor(e){this.view=e,this.tick=new o,this.lateTick=new o,this.audioListener=new a.AudioListener,e.onLoop((e=>{this.tick.next(e),this.lateTick.next(e)})),e.camera.add(this.audioListener),window.hology_view=this}set fpsCap(e){this.view.fpsCap=e}get fpsCap(){return this.view.fpsCap}set showStats(e){this.view.showStats=e}get showStats(){return this.view.showStats}addPostProcessVolume(e){this.view.addPostProcessVolume(e)}removePostProcessVolume(e){this.view.removePostProcessVolume(e)}onUpdate(e){return null!=e&&this.tick.pipe(n(e.disposed)),this.tick}onLateUpdate(e){return null!=e&&this.lateTick.pipe(n(e.disposed)),this.lateTick}setCamera(e){const t=e instanceof s?e:e.camera.instance;this.view.setCamera(t),t.add(this.audioListener)}getCamera(){return this.view.camera}get htmlElement(){return this.view.container}pauseRendering(){this.view.paused=!0}unpauseRendering(){this.view.paused=!1}dispose(){this.view.stop(),this.audioListener.removeFromParent()}getScreenPosition(e,t=p){const i=this.getCamera();return i.updateMatrixWorld(),m.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),i instanceof a.PerspectiveCamera&&(c.setFromProjectionMatrix(m),!c.containsPoint(e))?null:(t.copy(e),t.project(i),t.x=(t.x+1)/2*this.htmlElement.clientWidth,t.y=(1-t.y)/2*this.htmlElement.clientHeight,t)}};h=e([i(),t("design:paramtypes",[r])],h);export{h as ViewController};const m=new a.Matrix4,p=new a.Vector3,c=new a.Frustum;/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as r,__metadata as t}from"tslib";import{Service as s}from"typedi";let e=class{constructor(r=[]){this.shaders=r}get(r){return this.shaders.find((t=>t.name===r))}};e=r([s(),t("design:paramtypes",[Array])],e);export{e as ShaderProvider};/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{__decorate as t,__metadata as i}from"tslib";import{Service as s}from"typedi";import{ActorFactory as e}from"../actors/factory.js";import{Vector3 as o}from"three";import{ActorComponent as r}from"../../gameplay/actors/component.js";import{Subject as n}from"rxjs";import{RenderingView as c}from"../../rendering.js";import{PhysicsSystem as h}from"./physics/physics-system.js";const a=new o;class m{constructor(t){this.view=t}get direction(){return this.view.csm.lightDirection}set intensity(t){this.view.csm.lightIntensity=t,this.view.csm.lights.forEach((t=>t.intensity=this.view.csm.lightIntensity))}get intensity(){return this.view.csm.lightIntensity}get position(){return 0==this.view.csm.lights.length?a:this.view.csm.lights[0].position}}let p=class{constructor(t,i,s){this.actorFactory=t,this.view=i,this.physics=s,this.actors=[],this.actorAdded=new n,this.actorRemoved=new n,this.directionalLight=new m(this.view)}async spawnActor(t,i,s){const e=await this.actorFactory.create(t,i,s);return this.addActor(e,i,s),e}addActor(t,i,s){i&&t.object.position.copy(i),s&&t.object.rotation.copy(s),this.scene.add(t.object),this.actors.push(t),d(t,(t=>t.onBeginPlay())),this.actorAdded.next(t)}removeActor(t){d(t,(t=>t.onEndPlay()));const i=this.actors.indexOf(t);i>=0&&this.actors.splice(i,1),this.scene.remove(t.object),t.disposed.next(!0),this.actorRemoved.next(t)}findActorByType(t,i){return this.actors.find((s=>s instanceof t&&(null==i||s.object.name==i)))}findActorsByType(t,i){return this.actors.filter((s=>s instanceof t&&(null==i||s.object.name==i)))}};p=t([s(),i("design:paramtypes",[e,c,h])],p);export{p as World};function d(t,i){return i(t),Object.entries(t).filter((([t,i])=>i instanceof r)).forEach((([t,s])=>{d(s,i)}))}/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
export{loadScene}from"./scene/bootstrap.js";export{BaseGameController}from"./controllers/base-game-controller.js";export*from"./scene/collision/collision-shape.js";export{AssetMeshInstance}from"./scene/asset-resource-loader.js";export{registerWorker,initWorker}from"./worker";export*from"./shader";export*from"./gameplay/actors/builtin/post-process-volume-actor.js";/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"color-pass.d.ts","sourceRoot":"","sources":["../../src/rendering/color-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,MAAM,OAAO,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,qBAAa,SAAU,SAAQ,UAAU;IAEvC,OAAO,CAAC,OAAO,CAEd;IAED,IAAI,eAAe,CAAC,KAAK,EAAE,OAAO,EAEjC;IACD,IAAI,eAAe,IAHQ,OAAO,CAKjC;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAMlC;IACD,IAAI,iBAAiB,IAPQ,MAAM,CASlC;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,EAEzB;IACD,IAAI,SAAS,IAHQ,KAAK,CASzB;IACD,IAAI,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAEnC;IACD,IAAI,kBAAkB,IAHQ,MAAM,CAKnC;IAED,IAAI,WAAW,CAAC,KAAK,EAAE,MAAM,EAG5B;IACD,IAAI,WAAW,IAJQ,MAAM,CAM5B;IAED,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,EAGhC;IACD,IAAI,eAAe,IAJQ,MAAM,CAMhC;;
|
1
|
+
{"version":3,"file":"color-pass.d.ts","sourceRoot":"","sources":["../../src/rendering/color-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,MAAM,OAAO,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,qBAAa,SAAU,SAAQ,UAAU;IAEvC,OAAO,CAAC,OAAO,CAEd;IAED,IAAI,eAAe,CAAC,KAAK,EAAE,OAAO,EAEjC;IACD,IAAI,eAAe,IAHQ,OAAO,CAKjC;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAMlC;IACD,IAAI,iBAAiB,IAPQ,MAAM,CASlC;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,EAEzB;IACD,IAAI,SAAS,IAHQ,KAAK,CASzB;IACD,IAAI,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAEnC;IACD,IAAI,kBAAkB,IAHQ,MAAM,CAKnC;IAED,IAAI,WAAW,CAAC,KAAK,EAAE,MAAM,EAG5B;IACD,IAAI,WAAW,IAJQ,MAAM,CAM5B;IAED,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,EAGhC;IACD,IAAI,eAAe,IAJQ,MAAM,CAMhC;;CA4CF"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{Color as t,Texture as e,Vector3 as i}from"three";import{ShaderPass as n}from"three-stdlib";import{clamp as r,distance as s,float as u,ifDefApply as o,log as l,mix as a,NodeShaderMaterial as m,pow as c,select as p,smoothstep as f,uniformFloat as d,uniformSampler2d as v,uniformVec3 as
|
2
|
-
* Copyright (©)
|
1
|
+
import{Color as t,Texture as e,Vector3 as i}from"three";import{ShaderPass as n}from"three-stdlib";import{clamp as r,distance as s,float as u,ifDefApply as o,log as l,mix as a,NodeShaderMaterial as m,pow as c,select as p,smoothstep as f,uniformFloat as d,uniformSampler2d as v,uniformVec3 as g,varyingAttributes as T,vec2 as h,vec3 as y}from"../shader-nodes/index.js";export class ColorPass extends n{set vignetteEnabled(t){this.defines.USE_VIGNETTE=!!t}get vignetteEnabled(){return!!this.defines.USE_VIGNETTE}set vignetteIntensity(t){null!=this.material.uniforms.vignetteIntensity?this.material.uniforms.vignetteIntensity={value:t}:this.material.uniforms.vignetteIntensity.value=t}get vignetteIntensity(){return this.material.uniforms.vignetteIntensity?.value}set colorTint(t){this.uniforms.colorTint.value=t}get colorTint(){const e=this.uniforms.colorTint.value;return e instanceof t?e:(new t).setFromVector3(e)}set colorTintIntensity(t){this.uniforms.colorTintIntensity.value=t}get colorTintIntensity(){return this.uniforms.colorTintIntensity?.value}set temperature(t){this.uniforms.temperature&&(this.uniforms.temperature.value=t)}get temperature(){return this.uniforms.temperature?.value}set temperatureTint(t){this.uniforms.temperatureTint&&(this.uniforms.temperatureTint.value=t)}get temperatureTint(){return this.uniforms.temperatureTint?.value}constructor(){let t=v("tDiffuse",new e).sample(T.uv);const n=g("colorTint",new i(1,1,1)),I=d("colorTintIntensity",1);t=a(t.rgb,t.rgb.multiply(n),I).rgba(1);const E=d("temperature",6500),b=d("temperatureTint",0);t=function(t,e,i){function n(t){const e=t.divide(100),i=p(e.lte(66),u(1),r(u(1.292936186062745).multiply(c(e.subtract(60),-.1332047592)),0,1)),n=p(e.lte(66),r(u(.3900815787690196).multiply(l(e)).subtract(.6318414437886275),0,1),r(u(1.1298908608952942).multiply(c(e.subtract(60),-.0755148492)),0,1)),s=p(e.gte(66),u(1),p(e.lte(19),u(0),r(u(.543206789110196).multiply(l(e.subtract(10))).subtract(1.19625408914),0,1)));return y(i,n,s)}const s=n(r(e,1e3,4e4)),o=r(i,-1,1),a=y(1,u(1).add(o.multiply(.2)),1),m=s.multiply(a),f=m.divideScalar(m.y);return r(t.divide(f),y(0,0,0),y(1,1,1))}(t.rgb,E,b).rgba(1);const S=d("vignetteIntensity",.5),U=h(.5),V=s(T.uv,U),w=t.multiplyScalar(f(.8,.2*.799,V.multiply(S.add(.2))));t=o("USE_VIGNETTE",t,(()=>w));const G=new m({fog:!1,outputEncoding:!1,color:t});G.lights=!1,super(G),this.defines={USE_VIGNETTE:!1},G.defines=this.defines,G.needsUpdate=!0}}/*
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export const lambertVertexShaderOverride="\nvec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n float linearDepth = (-mvPosition.z) / (shadowFar - cameraNear);\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n #if ( UNROLLED_LOOP_INDEX < CSM_CASCADES )\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) {\n #endif \n getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n #endif\n #if ( UNROLLED_LOOP_INDEX < CSM_CASCADES )\n }\n #endif \n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n";export const shadowMaskOverride="\nvarying vec3 vViewPosition;\nfloat getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n // TODO this does not work as this varying does not exist in this shader\n float linearDepth = (-vViewPosition.z) / (shadowFar - cameraNear);\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n #if ( UNROLLED_LOOP_INDEX < CSM_CASCADES )\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) {\n #endif \n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #if ( UNROLLED_LOOP_INDEX < CSM_CASCADES )\n }\n #endif \n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}\n";/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import{NoToneMapping as e,ACESFilmicToneMapping as a,AgXToneMapping as n,CineonToneMapping as m,LinearToneMapping as l,NeutralToneMapping as u,ReinhardToneMapping as i}from"three";export const tonemapMappings=[{value:e,name:"None"},{value:l,name:"Linear"},{value:i,name:"Reinhard"},{value:m,name:"Cineon"},{value:a,name:"ACES Filmic"},{value:n,name:"AgX"},{value:u,name:"Neutral"}];/*
|
2
|
-
* Copyright (©)
|
2
|
+
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
3
3
|
* See the LICENSE.md file for details.
|
4
4
|
*/
|
package/dist/rendering.d.ts
CHANGED
package/dist/rendering.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,EAKN,QAAQ,EAIR,aAAa,EACb,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAGpD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAezE,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAwC1H,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,EAAE,CAAC,EAAE;QACH,OAAO,EAAE,OAAO,CAAA;KACjB,CAAA;CACF,CAAA;AAED,qBACa,aAAa;
|
1
|
+
{"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,EAKN,QAAQ,EAIR,aAAa,EACb,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAGpD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAezE,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAwC1H,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,EAAE,CAAC,EAAE;QACH,OAAO,EAAE,OAAO,CAAA;KACjB,CAAA;CACF,CAAA;AAED,qBACa,aAAa;IA6Jf,SAAS,EAAE,WAAW;aACb,OAAO,EAAE,oBAAoB;IA7JxC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAA;IACpB,aAAa,UAAO;IACpB,QAAQ,EAAE,aAAa,CAAA;IACvB,aAAa,EAAE,aAAa,CAAA;IACnC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,WAAW,CAAa;IACzB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAA;IAClB,OAAO,UAAO;IACd,MAAM,UAAQ;IACd,uBAAuB,EAAE,iBAAiB,CAAA;IAC1C,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,sBAAsB,EAAE,iBAAiB,CAAA;IACzC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAO;IAC5B,kBAAkB,EAAE,iBAAiB,EAAE,CAAK;IAC5C,mBAAmB,EAAS,mBAAmB,CAAA;IAE/C,MAAM,EAAE,QAAQ,CAAA;IACvB,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,OAAO,CAAS;IAIjB,SAAS,CAAC,KAAK,EAAE,OAAO;IAsBxB,eAAe,SAAqB;IAEpC,aAAa,SAA0C;IAE9D,OAAO,CAAC,QAAQ,CAQf;IAED,OAAO,CAAC,kBAAkB,CAAA;IAC1B,OAAO,CAAC,oBAAoB,CAAA;IAC5B,OAAO,CAAC,YAAY;IAwDb,oBAAoB,CAAC,MAAM,EAAE,iBAAiB;IAoB9C,uBAAuB,CAAC,MAAM,EAAE,iBAAiB;IAOxD,OAAO,CAAC,gBAAgB,CAEvB;IAED,OAAO,CAAC,gCAAgC,CAAQ;IAEhD,OAAO,CAAC,aAAa,CAAe;gBAG3B,SAAS,EAAE,WAAW,EACb,OAAO,GAAE,oBAAyB;IA6VpD,OAAO,CAAC,aAAa;IASd,SAAS,CAAC,MAAM,EAAE,MAAM;IAiDxB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE;IAkBzC,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAyBtC,OAAO;IACP,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAuB5C,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAuB3C,OAAO,CAAC,mBAAmB;IAMpB,IAAI;IAeX,OAAO,CAAC,eAAe,CAAK;IACrB,MAAM,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,GAAG;IAG1C,YAAY,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,GAAG;IAKvD,OAAO,CAAC,KAAK,CAST;IACJ,OAAO,CAAC,UAAU,CAAO;IAEzB,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAO3B;IACD,IAAI,SAAS,IARQ,OAAO,CAU3B;IAED,OAAO,CAAC,WAAW;IAsBZ,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,GAAG,EAAE,SAAS,UAAQ;IAqSlE,OAAO,CAAC,wBAAwB;IAkMhC,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,CAAC,cAAc,CAAyB;IAE/C,OAAO,CAAC,aAAa;IAyBd,gBAAgB,CAAC,MAAM,EAAE,MAAM;IAI/B,mBAAmB;IAInB,mBAAmB,CAAC,MAAM,EAAE,MAAM;IAIzC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAQ;IACjB,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM;IA+ChC,OAAO,CAAC,oBAAoB,CAAK;IACjC,OAAO,CAAC,WAAW,CAAiB;IAEpC,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,qBAAqB;CAe9B;AAgBD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,QAIhD;AAiHD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,OAAO,CAIzF"}
|