@hology/core 0.0.32 → 0.0.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. package/dist/csm.d.ts +1 -1
  2. package/dist/csm.js +1 -1
  3. package/dist/effects/vfx/index.d.ts +2 -2
  4. package/dist/effects/vfx/index.js +1 -1
  5. package/dist/effects/vfx/initializsers.d.ts +14 -7
  6. package/dist/effects/vfx/initializsers.js +1 -1
  7. package/dist/effects/vfx/vfx-actor.d.ts +2 -2
  8. package/dist/effects/vfx/vfx-actor.js +1 -1
  9. package/dist/effects/vfx/vfx-asset.d.ts +3 -3
  10. package/dist/effects/vfx/vfx-asset.js +1 -1
  11. package/dist/effects/vfx/vfx-defs.d.ts +5 -2
  12. package/dist/effects/vfx/vfx-defs.js +1 -1
  13. package/dist/effects/vfx/vfx-materializer.d.ts +1 -1
  14. package/dist/effects/vfx/vfx-materializer.js +1 -1
  15. package/dist/effects/vfx/vfx-param.d.ts +1 -1
  16. package/dist/gameplay/actors/actor.d.ts +1 -1
  17. package/dist/gameplay/actors/actor.js +1 -1
  18. package/dist/gameplay/actors/builtin/camera-actor.d.ts +3 -3
  19. package/dist/gameplay/actors/builtin/camera-actor.js +1 -1
  20. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -3
  21. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  22. package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts +4 -4
  23. package/dist/gameplay/actors/builtin/components/character/character-movement copy.js +1 -1
  24. package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +4 -4
  25. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  26. package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +2 -2
  27. package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
  28. package/dist/gameplay/actors/builtin/components/scene-component.d.ts +1 -1
  29. package/dist/gameplay/actors/builtin/components/scene-component.js +1 -1
  30. package/dist/gameplay/actors/builtin/index.d.ts +4 -4
  31. package/dist/gameplay/actors/builtin/index.js +1 -1
  32. package/dist/gameplay/actors/builtin/positional-audio-actor.d.ts +6 -5
  33. package/dist/gameplay/actors/builtin/positional-audio-actor.js +1 -1
  34. package/dist/gameplay/actors/builtin/spawn-point.d.ts +3 -3
  35. package/dist/gameplay/actors/builtin/spawn-point.js +1 -1
  36. package/dist/gameplay/actors/builtin/trigger-volume.d.ts +4 -4
  37. package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
  38. package/dist/gameplay/actors/camera/camera-component.d.ts +2 -2
  39. package/dist/gameplay/actors/camera/camera-component.js +1 -1
  40. package/dist/gameplay/actors/camera/third-party-camera-component.d.ts +5 -5
  41. package/dist/gameplay/actors/camera/third-party-camera-component.js +1 -1
  42. package/dist/gameplay/actors/component.d.ts +1 -1
  43. package/dist/gameplay/actors/component.js +1 -1
  44. package/dist/gameplay/actors/factory.d.ts +3 -3
  45. package/dist/gameplay/actors/factory.js +1 -1
  46. package/dist/gameplay/actors/index.d.ts +10 -10
  47. package/dist/gameplay/actors/index.js +1 -1
  48. package/dist/gameplay/actors/internal/component-init.d.ts +2 -2
  49. package/dist/gameplay/actors/internal/component-init.js +1 -1
  50. package/dist/gameplay/actors/internal/container-map.d.ts +1 -1
  51. package/dist/gameplay/animation/anim-sm.js +1 -1
  52. package/dist/gameplay/index.d.ts +14 -13
  53. package/dist/gameplay/index.js +1 -1
  54. package/dist/gameplay/initiate.d.ts +2 -2
  55. package/dist/gameplay/initiate.js +1 -1
  56. package/dist/gameplay/inject.js +1 -1
  57. package/dist/gameplay/input/index.d.ts +3 -3
  58. package/dist/gameplay/input/index.js +1 -1
  59. package/dist/gameplay/input/input-service.d.ts +1 -1
  60. package/dist/gameplay/input/input-service.js +1 -1
  61. package/dist/gameplay/input/input.js +1 -1
  62. package/dist/gameplay/services/asset-loader.d.ts +5 -5
  63. package/dist/gameplay/services/asset-loader.js +1 -1
  64. package/dist/gameplay/services/physics/physics-system.d.ts +5 -5
  65. package/dist/gameplay/services/physics/physics-system.js +1 -1
  66. package/dist/gameplay/services/pointer-events.d.ts +58 -0
  67. package/dist/gameplay/services/pointer-events.js +5 -0
  68. package/dist/gameplay/services/render.d.ts +3 -3
  69. package/dist/gameplay/services/render.js +1 -1
  70. package/dist/gameplay/services/world.d.ts +2 -2
  71. package/dist/gameplay/services/world.js +1 -1
  72. package/dist/index.d.ts +4 -4
  73. package/dist/index.js +1 -1
  74. package/dist/rendering.js +1 -1
  75. package/dist/scene/asset-resource-loader.d.ts +4 -2
  76. package/dist/scene/asset-resource-loader.js +1 -1
  77. package/dist/scene/assets-provider.d.ts +1 -1
  78. package/dist/scene/bootstrap.d.ts +7 -7
  79. package/dist/scene/bootstrap.js +1 -1
  80. package/dist/scene/collision/collision-shape-import.d.ts +1 -1
  81. package/dist/scene/collision/collision-shape-import.js +1 -1
  82. package/dist/scene/landscape/landscape-manager.d.ts +6 -6
  83. package/dist/scene/landscape/landscape-manager.js +1 -1
  84. package/dist/scene/landscape/landscape.js +1 -1
  85. package/dist/scene/landscape/utils.d.ts +1 -1
  86. package/dist/scene/landscape/utils.js +1 -1
  87. package/dist/scene/materializer.d.ts +10 -10
  88. package/dist/scene/materializer.js +1 -1
  89. package/dist/scene/materials/grass-foliage.d.ts +2 -2
  90. package/dist/scene/materials/grass-foliage.js +1 -1
  91. package/dist/scene/materials/grass.d.ts +1 -1
  92. package/dist/scene/materials/grass.js +1 -1
  93. package/dist/scene/materials/water.d.ts +1 -1
  94. package/dist/scene/materials/water.js +1 -1
  95. package/dist/scene/model.d.ts +5 -5
  96. package/dist/scene/objects/shapes.d.ts +3 -3
  97. package/dist/scene/objects/shapes.js +1 -1
  98. package/dist/scene/runtime-asset-service.d.ts +4 -3
  99. package/dist/scene/runtime-asset-service.js +1 -1
  100. package/dist/scene/runtime-backend-service.d.ts +1 -1
  101. package/dist/scene/runtime-backend-service.js +1 -1
  102. package/dist/scene/scene-data-service.d.ts +1 -1
  103. package/dist/scene/scene-data-service.js +1 -1
  104. package/dist/scene/storage/storage.js +1 -1
  105. package/dist/shader/builtin/index.d.ts +2 -2
  106. package/dist/shader/builtin/index.js +1 -1
  107. package/dist/shader/builtin/lambert-shader.d.ts +1 -1
  108. package/dist/shader/builtin/lambert-shader.js +1 -1
  109. package/dist/shader/builtin/standard-shader.d.ts +1 -1
  110. package/dist/shader/builtin/standard-shader.js +1 -1
  111. package/dist/shader/index.d.ts +3 -3
  112. package/dist/shader/index.js +1 -1
  113. package/dist/shader/parameter.d.ts +4 -4
  114. package/dist/shader/parameter.js +1 -1
  115. package/dist/shader/shader.d.ts +4 -4
  116. package/dist/shader/shader.js +1 -1
  117. package/dist/shader-nodes/effects.js +1 -1
  118. package/dist/shader-nodes/index.d.ts +9 -9
  119. package/dist/shader-nodes/index.js +1 -1
  120. package/dist/shader-nodes/layers.js +1 -1
  121. package/dist/test/injection.test.js +1 -1
  122. package/dist/utils/collections.js +1 -1
  123. package/dist/utils/three/depth-pass.js +1 -1
  124. package/dist/utils/three/outline-pass.d.ts +2 -2
  125. package/dist/utils/three/transform-controls.d.ts +2 -2
  126. package/package.json +6 -7
  127. package/tsconfig.tsbuildinfo +1 -1
  128. package/dist/utils/cannon/CannonUtils.d.ts +0 -17
  129. package/dist/utils/cannon/CannonUtils.js +0 -5
  130. package/dist/utils/cannon/three-to-cannon/ConvexHull.d.ts +0 -47
  131. package/dist/utils/cannon/three-to-cannon/ConvexHull.js +0 -5
  132. package/dist/utils/cannon/three-to-cannon/index.d.ts +0 -63
  133. package/dist/utils/cannon/three-to-cannon/index.js +0 -5
  134. package/dist/utils/cannon/three-to-cannon/utils.d.ts +0 -9
  135. package/dist/utils/cannon/three-to-cannon/utils.js +0 -5
@@ -1,4 +1,4 @@
1
- import*as e from"three";import{CSMUtil as r}from"../../csm";import{noiseChunk as n}from"./utils/noise.glsl";export function createGrassMaterial(a,i){var t=new e.MeshStandardMaterial({color:a.color,roughness:.8,metalness:0});return t.onBeforeCompile=(e,i)=>{r.onBeforeCompile(t,e);const l="varying vec3 vViewPosition;",v=`${l}\n varying vec3 vOriginalNormal;\n varying vec2 vNoiseCoord;\n attribute vec3 material;\n varying vec3 vMaterial;\n `,c="#include <fog_vertex>",s=`${c}\n vOriginalNormal = objectNormal;\n vMaterial = material;\n vNoiseCoord = position.xz / 5.0;\n `;e.vertexShader=e.vertexShader.replace(l,v),e.vertexShader=e.vertexShader.replace(c,s);const d="uniform vec3 diffuse;",m=`${d}\n varying vec3 vOriginalNormal;\n varying vec3 vMaterial;\n varying vec2 vNoiseCoord;\n\n ${n}\n `,g=o(a.color),f=o(a.colorTwo),h=`\n float thresholdStatic = 0.5;\n float thresholdWithNoise = thresholdStatic + snoise(vNoiseCoord) * 0.1;\n vec3 painted = (\n vMaterial.y > thresholdWithNoise \n ? ${o(a.colorThree)}\n : (vMaterial.x > thresholdWithNoise\n ? ${f}\n : ${g}\n )\n );\n\n float colorAngle = pow(vOriginalNormal.y, 3.0);\n vec4 diffuseColor = vec4(mix(painted, ${f}, smoothstep(colorAngle-0.0003, colorAngle, 0.9)), opacity);\n `.trim();e.fragmentShader=e.fragmentShader.replace(d,m),e.fragmentShader=e.fragmentShader.replace("vec4 diffuseColor = vec4( diffuse, opacity );",h)},t.userData.instancing=!1,t.userData.grass=!0,t}function o(e){return`vec3(${e.r.toFixed(5)}, ${e.g.toFixed(5)}, ${e.b.toFixed(5)})`}export function createGrassMaterialOld(r,n){return new e.ShaderMaterial({uniforms:{colorOne:{value:r.color}},vertexShader:"\n uniform float time;\n varying vec3 vNormal;\n void main() {\n vNormal = normal;\n #include <begin_vertex>\n #include <project_vertex>\n #include <fog_vertex>\n }",fragmentShader:"\n varying vec3 vNormal;\n uniform vec3 colorOne;\n void main() {\n gl_FragColor = vec4(mix(colorOne, vec3(.86,.8,.7), step(pow(vNormal.y, 3.0), 0.9)), 1.0);\t\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n }"})}
1
+ import*as e from"three";import{CSMUtil as r}from"../../csm.js";import{noiseChunk as n}from"./utils/noise.glsl.js";export function createGrassMaterial(a,i){var t=new e.MeshStandardMaterial({color:a.color,roughness:.8,metalness:0});return t.onBeforeCompile=(e,i)=>{r.onBeforeCompile(t,e);const l="varying vec3 vViewPosition;",v=`${l}\n varying vec3 vOriginalNormal;\n varying vec2 vNoiseCoord;\n attribute vec3 material;\n varying vec3 vMaterial;\n `,c="#include <fog_vertex>",s=`${c}\n vOriginalNormal = objectNormal;\n vMaterial = material;\n vNoiseCoord = position.xz / 5.0;\n `;e.vertexShader=e.vertexShader.replace(l,v),e.vertexShader=e.vertexShader.replace(c,s);const d="uniform vec3 diffuse;",m=`${d}\n varying vec3 vOriginalNormal;\n varying vec3 vMaterial;\n varying vec2 vNoiseCoord;\n\n ${n}\n `,g=o(a.color),f=o(a.colorTwo),h=`\n float thresholdStatic = 0.5;\n float thresholdWithNoise = thresholdStatic + snoise(vNoiseCoord) * 0.1;\n vec3 painted = (\n vMaterial.y > thresholdWithNoise \n ? ${o(a.colorThree)}\n : (vMaterial.x > thresholdWithNoise\n ? ${f}\n : ${g}\n )\n );\n\n float colorAngle = pow(vOriginalNormal.y, 3.0);\n vec4 diffuseColor = vec4(mix(painted, ${f}, smoothstep(colorAngle-0.0003, colorAngle, 0.9)), opacity);\n `.trim();e.fragmentShader=e.fragmentShader.replace(d,m),e.fragmentShader=e.fragmentShader.replace("vec4 diffuseColor = vec4( diffuse, opacity );",h)},t.userData.instancing=!1,t.userData.grass=!0,t}function o(e){return`vec3(${e.r.toFixed(5)}, ${e.g.toFixed(5)}, ${e.b.toFixed(5)})`}export function createGrassMaterialOld(r,n){return new e.ShaderMaterial({uniforms:{colorOne:{value:r.color}},vertexShader:"\n uniform float time;\n varying vec3 vNormal;\n void main() {\n vNormal = normal;\n #include <begin_vertex>\n #include <project_vertex>\n #include <fog_vertex>\n }",fragmentShader:"\n varying vec3 vNormal;\n uniform vec3 colorOne;\n void main() {\n gl_FragColor = vec4(mix(colorOne, vec3(.86,.8,.7), step(pow(vNormal.y, 3.0), 0.9)), 1.0);\t\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n }"})}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,3 +1,3 @@
1
1
  import * as THREE from 'three';
2
- import { RenderingView } from '../../rendering';
2
+ import { RenderingView } from '../../rendering.js';
3
3
  export declare function createWaterMaterial(params: any, renderingView: RenderingView): THREE.ShaderMaterial;
@@ -1,4 +1,4 @@
1
- import*as e from"three";import{Color as n,DoubleSide as r,PerspectiveCamera as t}from"three";export function createWaterMaterial(a,o){var i;const l=(new e.TextureLoader).load("https://i.imgur.com/hOIsXiZ.png"),m=(new e.TextureLoader).load("assets/images/shaders/water_normal_map.jpg");m.wrapS=e.MirroredRepeatWrapping,m.wrapT=e.MirroredRepeatWrapping;const c={time:{value:0},threshold:{value:.1},tDudv:{value:null},tDepth:{value:null},cameraNear:{value:0},cameraFar:{value:0},resolution:{value:new e.Vector2},foamColor:{value:new e.Color},waterColor:{value:new e.Color},normalMap:{value:null}};l.wrapS=l.wrapT=e.RepeatWrapping;var s=!!o.renderer.extensions.get("WEBGL_depth_texture"),u=new e.ShaderMaterial({defines:{DEPTH_PACKING:!0===s?0:1,ORTHOGRAPHIC_CAMERA:0},uniforms:e.UniformsUtils.merge([e.UniformsLib.fog,c]),transparent:!0,vertexShader:"\n #include <fog_pars_vertex>\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n\n \t#include <begin_vertex>\n \t#include <project_vertex>\n \t#include <fog_vertex>\n\n }",fragmentShader:"\n #include <common>\n #include <packing>\n #include <fog_pars_fragment>\n\n varying vec2 vUv;\n uniform sampler2D tDepth;\n uniform sampler2D tDudv;\n uniform vec3 waterColor;\n uniform vec3 foamColor;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float time;\n uniform float threshold;\n uniform vec2 resolution;\n uniform sampler2D normalMap;\n\n float getDepth( const in vec2 screenPosition ) {\n #if DEPTH_PACKING == 1\n return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n #else\n return texture2D( tDepth, screenPosition ).x;\n #endif\n }\n\n float getViewZ( const in float depth ) {\n #if ORTHOGRAPHIC_CAMERA == 1\n return orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n #else\n return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n #endif\n }\n\n void main() {\n\n vec2 screenUV = gl_FragCoord.xy / resolution;\n\n float fragmentLinearEyeDepth = getViewZ( gl_FragCoord.z );\n float linearEyeDepth = getViewZ( getDepth( screenUV ) );\n\n float diff = saturate(fragmentLinearEyeDepth - linearEyeDepth);\n // Increase foam length by negating more\n //float diff = saturate(fragmentLinearEyeDepth - linearEyeDepth - 5.0);\n\n vec2 displacement = texture2D( tDudv, ( vUv * 2.0 ) - time * 0.01 ).rb;\n displacement = ( ( displacement * 2.0 ) - 1.0 ) * 1.0;\n diff += displacement.x*0.3; // How much of the texture to apply\n/*\n if (diff < 0.4 * ((sin(time*.5)*1.5+2.0)/5.0) && diff > 0.1 * ((sin(time*.5)*1.5+2.0)/5.0)) {\n diff = 1.0; \n // This illustrates how one can create stripes of foam so it does not start at the short\n }*/\n\n float depth = (linearEyeDepth - fragmentLinearEyeDepth) / linearEyeDepth;\n vec3 waterDiffuse = mix( foamColor, mix(vec3(0.2, 0.3, 0.7), waterColor, 1.0 - depth), step( 0.9*((sin(time*.5)*2.0+3.0)/5.0), diff ) );\n gl_FragColor.a = 0.8-clamp(depth, 0.3, 0.8)/3.0;\n\n\n // This light direction is hard coded but should be coming from the directional lights\n vec3 lightDirection = normalize(vec3(0.5, -1.0, -0.6) * -1.0);\n vec2 waterCoord = vUv;\n // Create some randomnes when picking coordinates.\n waterCoord.x *= 1.5 - cos(time) * 0.02;\n waterCoord.y *= 1.5 - sin(time+5.0) * 0.01;\n vec3 wNormal = texture2D(normalMap, waterCoord).rgb;\n float dotNL = clamp(dot(wNormal, lightDirection), 0.0, 1.0);\n vec3 irradience = dotNL * vec3(1.0);\n\n gl_FragColor.rgb = waterDiffuse * 0.2 + waterDiffuse * irradience * 1.3;\n\n //gl_FragColor.rgb = irradience;//texture2D(normalMap, vUv * 2.0).rgb;\n //gl_FragColor.a = 1.0;\n\n\n //vec4 foam = vec4(foamColor, 1.0);\n //vec4 murky = vec4(0.2, 0.3, 0.7, 0.9);\n //vec4 water = vec4(waterColor, 0.5);\n //gl_FragColor = mix(foam, mix(murky, water, 1.0 - depth), step( 0.9*((sin(time*.5)*2.0+3.0)/5.0), diff ) );\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n\n }",fog:!0,side:r,blendSrc:e.OneMinusSrcColorFactor,blendDst:e.SrcColorFactor});u.uniforms.cameraNear.value=o.camera instanceof t?o.camera.near:1,u.uniforms.cameraFar.value=o.camera instanceof t?o.camera.far:500,u.uniforms.foamColor.value.set(new n(16777215)),u.uniforms.waterColor.value.set(null!==(i=a.color)&&void 0!==i?i:new n(2084067)),u.uniforms.resolution.value.set(o.container.clientWidth*o.renderer.getPixelRatio(),o.container.clientHeight*o.renderer.getPixelRatio()),u.uniforms.tDudv.value=l,u.uniforms.tDepth.value=!0===s?o.depthRenderTarget.depthTexture:o.depthRenderTarget.texture,u.uniforms.normalMap.value=m;let f=0;return o.onLoop((e=>{f+=e,u.uniforms.threshold.value=.5,u.uniforms.time.value=f,u.uniforms.resolution.value.set(o.container.clientWidth*o.renderer.getPixelRatio(),o.container.clientHeight*o.renderer.getPixelRatio())})),u.userData.water=!0,u}
1
+ import*as e from"three";import{Color as n,DoubleSide as r,PerspectiveCamera as t}from"three";export function createWaterMaterial(a,o){const i=(new e.TextureLoader).load("https://i.imgur.com/hOIsXiZ.png"),l=(new e.TextureLoader).load("assets/images/shaders/water_normal_map.jpg");l.wrapS=e.MirroredRepeatWrapping,l.wrapT=e.MirroredRepeatWrapping;const m={time:{value:0},threshold:{value:.1},tDudv:{value:null},tDepth:{value:null},cameraNear:{value:0},cameraFar:{value:0},resolution:{value:new e.Vector2},foamColor:{value:new e.Color},waterColor:{value:new e.Color},normalMap:{value:null}};i.wrapS=i.wrapT=e.RepeatWrapping;var c=!!o.renderer.extensions.get("WEBGL_depth_texture"),s=new e.ShaderMaterial({defines:{DEPTH_PACKING:!0===c?0:1,ORTHOGRAPHIC_CAMERA:0},uniforms:e.UniformsUtils.merge([e.UniformsLib.fog,m]),transparent:!0,vertexShader:"\n #include <fog_pars_vertex>\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n\n \t#include <begin_vertex>\n \t#include <project_vertex>\n \t#include <fog_vertex>\n\n }",fragmentShader:"\n #include <common>\n #include <packing>\n #include <fog_pars_fragment>\n\n varying vec2 vUv;\n uniform sampler2D tDepth;\n uniform sampler2D tDudv;\n uniform vec3 waterColor;\n uniform vec3 foamColor;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float time;\n uniform float threshold;\n uniform vec2 resolution;\n uniform sampler2D normalMap;\n\n float getDepth( const in vec2 screenPosition ) {\n #if DEPTH_PACKING == 1\n return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n #else\n return texture2D( tDepth, screenPosition ).x;\n #endif\n }\n\n float getViewZ( const in float depth ) {\n #if ORTHOGRAPHIC_CAMERA == 1\n return orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n #else\n return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n #endif\n }\n\n void main() {\n\n vec2 screenUV = gl_FragCoord.xy / resolution;\n\n float fragmentLinearEyeDepth = getViewZ( gl_FragCoord.z );\n float linearEyeDepth = getViewZ( getDepth( screenUV ) );\n\n float diff = saturate(fragmentLinearEyeDepth - linearEyeDepth);\n // Increase foam length by negating more\n //float diff = saturate(fragmentLinearEyeDepth - linearEyeDepth - 5.0);\n\n vec2 displacement = texture2D( tDudv, ( vUv * 2.0 ) - time * 0.01 ).rb;\n displacement = ( ( displacement * 2.0 ) - 1.0 ) * 1.0;\n diff += displacement.x*0.3; // How much of the texture to apply\n/*\n if (diff < 0.4 * ((sin(time*.5)*1.5+2.0)/5.0) && diff > 0.1 * ((sin(time*.5)*1.5+2.0)/5.0)) {\n diff = 1.0; \n // This illustrates how one can create stripes of foam so it does not start at the short\n }*/\n\n float depth = (linearEyeDepth - fragmentLinearEyeDepth) / linearEyeDepth;\n vec3 waterDiffuse = mix( foamColor, mix(vec3(0.2, 0.3, 0.7), waterColor, 1.0 - depth), step( 0.9*((sin(time*.5)*2.0+3.0)/5.0), diff ) );\n gl_FragColor.a = 0.8-clamp(depth, 0.3, 0.8)/3.0;\n\n\n // This light direction is hard coded but should be coming from the directional lights\n vec3 lightDirection = normalize(vec3(0.5, -1.0, -0.6) * -1.0);\n vec2 waterCoord = vUv;\n // Create some randomnes when picking coordinates.\n waterCoord.x *= 1.5 - cos(time) * 0.02;\n waterCoord.y *= 1.5 - sin(time+5.0) * 0.01;\n vec3 wNormal = texture2D(normalMap, waterCoord).rgb;\n float dotNL = clamp(dot(wNormal, lightDirection), 0.0, 1.0);\n vec3 irradience = dotNL * vec3(1.0);\n\n gl_FragColor.rgb = waterDiffuse * 0.2 + waterDiffuse * irradience * 1.3;\n\n //gl_FragColor.rgb = irradience;//texture2D(normalMap, vUv * 2.0).rgb;\n //gl_FragColor.a = 1.0;\n\n\n //vec4 foam = vec4(foamColor, 1.0);\n //vec4 murky = vec4(0.2, 0.3, 0.7, 0.9);\n //vec4 water = vec4(waterColor, 0.5);\n //gl_FragColor = mix(foam, mix(murky, water, 1.0 - depth), step( 0.9*((sin(time*.5)*2.0+3.0)/5.0), diff ) );\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n\n }",fog:!0,side:r,blendSrc:e.OneMinusSrcColorFactor,blendDst:e.SrcColorFactor});s.uniforms.cameraNear.value=o.camera instanceof t?o.camera.near:1,s.uniforms.cameraFar.value=o.camera instanceof t?o.camera.far:500,s.uniforms.foamColor.value.set(new n(16777215)),s.uniforms.waterColor.value.set(a.color??new n(2084067)),s.uniforms.resolution.value.set(o.container.clientWidth*o.renderer.getPixelRatio(),o.container.clientHeight*o.renderer.getPixelRatio()),s.uniforms.tDudv.value=i,s.uniforms.tDepth.value=!0===c?o.depthRenderTarget.depthTexture:o.depthRenderTarget.texture,s.uniforms.normalMap.value=l;let f=0;return o.onLoop((e=>{f+=e,s.uniforms.threshold.value=.5,s.uniforms.time.value=f,s.uniforms.resolution.value.set(o.container.clientWidth*o.renderer.getPixelRatio(),o.container.clientHeight*o.renderer.getPixelRatio())})),s.userData.water=!0,s}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,9 +1,9 @@
1
- import { AttachedComponent, ActorSettings, SceneObject } from './materializer';
2
- import { ParticleSystemConfig } from '../effects/particles/particle-system-config';
3
- import { LandscapeInitOptions } from '../scene/landscape/landscape';
4
- import { LibraryShapeType } from './objects/shapes';
1
+ import { AttachedComponent, ActorSettings, SceneObject } from './materializer.js';
2
+ import { ParticleSystemConfig } from '../effects/particles/particle-system-config.js';
3
+ import { LandscapeInitOptions } from '../scene/landscape/landscape.js';
4
+ import { LibraryShapeType } from './objects/shapes.js';
5
5
  import { Side } from 'three';
6
- import { VfxAssetData } from '../effects/vfx/vfx-asset';
6
+ import { VfxAssetData } from '../effects/vfx/vfx-asset.js';
7
7
  export type AssetType = 'mesh' | 'material' | 'shape' | 'particles' | 'light' | 'texture' | 'actor' | 'audio' | 'prefab' | 'vfx';
8
8
  export type ShapeType = LibraryShapeType | 'landscape';
9
9
  export type LightType = 'point' | 'directional' | 'ambient';
@@ -1,7 +1,7 @@
1
- import { BoxCollisionShape, CapsuleCollisionShape, CollisionShape, ConeCollisionShape, ConvexPolyhedronCollisionShape, CylinderCollisionShape, PlaneCollisionShape, SphereCollisionShape, TrimeshCollisionShape } from "../collision/collision-shape";
1
+ import { BoxCollisionShape, CapsuleCollisionShape, CollisionShape, ConeCollisionShape, ConvexPolyhedronCollisionShape, CylinderCollisionShape, PlaneCollisionShape, SphereCollisionShape, TrimeshCollisionShape } from '../collision/collision-shape.js';
2
2
  import { BoxGeometry, PlaneGeometry, BufferGeometry, CylinderGeometry, SphereGeometry, TorusGeometry, ConeGeometry, CircleGeometry, CapsuleGeometry, Vector2 } from "three";
3
- import { RoundedBoxGeometry } from 'three/examples/jsm/geometries/RoundedBoxGeometry';
4
- import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry';
3
+ import { RoundedBoxGeometry } from 'three/examples/jsm/geometries/RoundedBoxGeometry.js';
4
+ import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry.js';
5
5
  import { Color } from "three-nebula";
6
6
  type AVec3 = [number, number, number];
7
7
  type ShapeParameterDef<T = boolean | number | string> = {
@@ -1,4 +1,4 @@
1
- import{BoxCollisionShape as e,CapsuleCollisionShape as t,ConeCollisionShape as r,ConvexPolyhedronCollisionShape as s,CylinderCollisionShape as n,PlaneCollisionShape as i,SphereCollisionShape as o,TrimeshCollisionShape as a}from"../collision/collision-shape";import{BoxGeometry as m,PlaneGeometry as h,Vector3 as l,CylinderGeometry as c,SphereGeometry as g,Euler as p,TorusGeometry as u,ConeGeometry as d,CircleGeometry as w,CapsuleGeometry as y}from"three";import{rampGeometry as S}from"./ramp-geometry";import{RoundedBoxGeometry as f}from"three/examples/jsm/geometries/RoundedBoxGeometry";import{TextGeometry as x}from"three/examples/jsm/geometries/TextGeometry";import{Font as b}from"three/examples/jsm/loaders/FontLoader";import*as j from"three/examples/fonts/helvetiker_regular.typeface.json";import{createSpiralStairsGeometry as L,createStairsGeometry as z}from"./stairs-geometry";function E(e){return{type:"number",default:e}}function k(e){return{type:"number",default:e,float:!0}}function v(e){return{type:"boolean",default:e}}function B(e,t){const r={};for(let s in t)null==e[s]?r[s]=t[s].default:r[s]=e[s];return r}const G={box:{geometry:()=>new m(1,1,1),collision:()=>new e(new l(1,1,1))},ramp:{geometry:()=>S(),collision:()=>new s(S())},plane:new class{constructor(){this.parameters={widthSegments:E(1),heightSegments:E(1)}}geometry(e={}){const t=B(e,this.parameters);return new h(1,1,t.widthSegments,t.heightSegments)}collision(e={}){return new i(1,1)}},cylinder:new class{constructor(){this.parameters={radialSegments:E(12),heightSegments:E(1),openEnded:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return new c(.5,.5,1,t.radialSegments,t.heightSegments,t.openEnded)}collision(e={}){const t=B(e,this.parameters);return new n(.5,.5,1,t.radialSegments,new p(0,1,0))}},sphere:new class{constructor(){this.parameters={withSegments:E(12),heightSegments:E(12)}}geometry(e={}){const t=B(e,this.parameters);return new g(.5,t.withSegments,t.heightSegments)}collision(){return new o(.5)}},torus:new class{constructor(){this.parameters={radius:k(1),tube:k(.3),radialSegments:E(16),tubularSegments:E(50)}}geometry(e={}){const t=B(e,this.parameters);return new u(t.radius,t.tube,t.radialSegments,t.tubularSegments)}collision(e={}){return new a(this.geometry(e))}},cone:new class{constructor(){this.parameters={radialSegments:E(12),heightSegments:E(1),openEnded:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return new d(.5,1,t.radialSegments,t.heightSegments)}collision(e={}){return new r(1,.5)}},circle:new class{constructor(){this.parameters={segments:E(32)}}geometry(e={}){const t=B(e,this.parameters);return new w(.5,t.segments)}collision(e={}){return new a(this.geometry(e))}},capsule:new class{constructor(){this.parameters={radius:k(.5),length:k(1),capSegments:E(8),radialSegments:E(32)}}geometry(e={}){const t=B(e,this.parameters);return new y(t.radius,t.length,t.capSegments,t.radialSegments)}collision(e={}){const r=B(e,this.parameters);return new t(r.length,r.radius)}},roundedBox:new class{constructor(){this.parameters={width:k(1),height:k(1),depth:k(1),segments:E(4),radius:k(.1)}}geometry(e={}){const t=B(e,this.parameters);return new f(t.width,t.height,t.depth,t.segments,t.radius)}collision(t={}){const r=B(t,this.parameters);return new e(new l(r.width,r.height,r.depth))}},text:new class{constructor(){var e;this.parameters={text:(e="Text",{type:"string",default:e}),size:k(1),depth:k(.2)}}geometry(e={}){const t=B(e,this.parameters);return new x(t.text,{font:new b(j),size:t.size,height:t.depth})}collision(e={}){return B(e,this.parameters).text.trim().length,null}},stairs:new class{constructor(){this.parameters={floating:v(!1),width:k(1),height:k(.25),depth:k(.25),steps:E(4)}}geometry(e={}){const t=B(e,this.parameters);return z(t.floating,t.steps,t.depth,t.height,t.width)}collision(e={}){return new a(this.geometry(e))}},stairsSpiral:new class{constructor(){this.parameters={floating:v(!1),width:k(1),height:k(.25),steps:E(4),degrees:E(90),radius:k(.2),flipped:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return L(t.floating,t.steps,t.height,t.width,t.degrees,t.radius,t.flipped)}collision(e={}){return new a(this.geometry(e))}}};export const ShapeLibrary=G;export const ShapeLibraryKeys=Object.keys(ShapeLibrary);
1
+ import{BoxCollisionShape as e,CapsuleCollisionShape as t,ConeCollisionShape as r,ConvexPolyhedronCollisionShape as s,CylinderCollisionShape as n,PlaneCollisionShape as i,SphereCollisionShape as o,TrimeshCollisionShape as a}from"../collision/collision-shape.js";import{BoxGeometry as m,PlaneGeometry as h,Vector3 as l,CylinderGeometry as c,SphereGeometry as g,Euler as p,TorusGeometry as u,ConeGeometry as d,CircleGeometry as w,CapsuleGeometry as y}from"three";import{rampGeometry as S}from"./ramp-geometry.js";import{RoundedBoxGeometry as f}from"three/examples/jsm/geometries/RoundedBoxGeometry.js";import{TextGeometry as x}from"three/examples/jsm/geometries/TextGeometry.js";import{Font as b}from"three/examples/jsm/loaders/FontLoader.js";import*as j from"three/examples/fonts/helvetiker_regular.typeface.json";import{createSpiralStairsGeometry as L,createStairsGeometry as z}from"./stairs-geometry.js";function E(e){return{type:"number",default:e}}function k(e){return{type:"number",default:e,float:!0}}function v(e){return{type:"boolean",default:e}}function B(e,t){const r={};for(let s in t)null==e[s]?r[s]=t[s].default:r[s]=e[s];return r}const G={box:{geometry:()=>new m(1,1,1),collision:()=>new e(new l(1,1,1))},ramp:{geometry:()=>S(),collision:()=>new s(S())},plane:new class{constructor(){this.parameters={widthSegments:E(1),heightSegments:E(1)}}geometry(e={}){const t=B(e,this.parameters);return new h(1,1,t.widthSegments,t.heightSegments)}collision(e={}){return new i(1,1)}},cylinder:new class{constructor(){this.parameters={radialSegments:E(12),heightSegments:E(1),openEnded:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return new c(.5,.5,1,t.radialSegments,t.heightSegments,t.openEnded)}collision(e={}){const t=B(e,this.parameters);return new n(.5,.5,1,t.radialSegments,new p(0,1,0))}},sphere:new class{constructor(){this.parameters={withSegments:E(12),heightSegments:E(12)}}geometry(e={}){const t=B(e,this.parameters);return new g(.5,t.withSegments,t.heightSegments)}collision(){return new o(.5)}},torus:new class{constructor(){this.parameters={radius:k(1),tube:k(.3),radialSegments:E(16),tubularSegments:E(50)}}geometry(e={}){const t=B(e,this.parameters);return new u(t.radius,t.tube,t.radialSegments,t.tubularSegments)}collision(e={}){return new a(this.geometry(e))}},cone:new class{constructor(){this.parameters={radialSegments:E(12),heightSegments:E(1),openEnded:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return new d(.5,1,t.radialSegments,t.heightSegments)}collision(e={}){return new r(1,.5)}},circle:new class{constructor(){this.parameters={segments:E(32)}}geometry(e={}){const t=B(e,this.parameters);return new w(.5,t.segments)}collision(e={}){return new a(this.geometry(e))}},capsule:new class{constructor(){this.parameters={radius:k(.5),length:k(1),capSegments:E(8),radialSegments:E(32)}}geometry(e={}){const t=B(e,this.parameters);return new y(t.radius,t.length,t.capSegments,t.radialSegments)}collision(e={}){const r=B(e,this.parameters);return new t(r.length,r.radius)}},roundedBox:new class{constructor(){this.parameters={width:k(1),height:k(1),depth:k(1),segments:E(4),radius:k(.1)}}geometry(e={}){const t=B(e,this.parameters);return new f(t.width,t.height,t.depth,t.segments,t.radius)}collision(t={}){const r=B(t,this.parameters);return new e(new l(r.width,r.height,r.depth))}},text:new class{constructor(){var e;this.parameters={text:(e="Text",{type:"string",default:e}),size:k(1),depth:k(.2)}}geometry(e={}){const t=B(e,this.parameters);return new x(t.text,{font:new b(j),size:t.size,height:t.depth})}collision(e={}){return B(e,this.parameters).text.trim().length,null}},stairs:new class{constructor(){this.parameters={floating:v(!1),width:k(1),height:k(.25),depth:k(.25),steps:E(4)}}geometry(e={}){const t=B(e,this.parameters);return z(t.floating,t.steps,t.depth,t.height,t.width)}collision(e={}){return new a(this.geometry(e))}},stairsSpiral:new class{constructor(){this.parameters={floating:v(!1),width:k(1),height:k(.25),steps:E(4),degrees:E(90),radius:k(.2),flipped:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return L(t.floating,t.steps,t.height,t.width,t.degrees,t.radius,t.flipped)}collision(e={}){return new a(this.geometry(e))}}};export const ShapeLibrary=G;export const ShapeLibraryKeys=Object.keys(ShapeLibrary);
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,10 +1,11 @@
1
- import { AssetsProvider } from '../scene/assets-provider';
1
+ import { AssetsProvider } from '../scene/assets-provider.js';
2
2
  import { Subject } from 'rxjs';
3
- import { Asset } from '../scene/model';
4
- import { RuntimeBackendService } from './runtime-backend-service';
3
+ import { Asset } from '../scene/model.js';
4
+ import { RuntimeBackendService } from './runtime-backend-service.js';
5
5
  export declare class RuntimeAssetsService implements AssetsProvider {
6
6
  private backend;
7
7
  private assets;
8
+ private loaded;
8
9
  onCreate: Subject<Asset>;
9
10
  onDelete: Subject<Asset>;
10
11
  onUpdate: Subject<Asset>;
@@ -1,4 +1,4 @@
1
- import{__awaiter as t}from"tslib";import{Subject as s}from"rxjs";export class RuntimeAssetsService{constructor(t){this.backend=t,this.assets=new Map,this.onCreate=new s,this.onDelete=new s,this.onUpdate=new s}getAssets(){return t(this,void 0,void 0,(function*(){return Array.from(this.assets.values())}))}getAsset(s){var n;return t(this,void 0,void 0,(function*(){return null!==(n=this.assets.get(s))&&void 0!==n?n:function(s,n){return t(this,void 0,void 0,(function*(){return e.has(s)||e.set(s,n(s)),e.get(s)}))}(s,(()=>this.backend.getAsset(s)))}))}}const e=new Map;
1
+ import{Subject as s}from"rxjs";export class RuntimeAssetsService{constructor(t){this.backend=t,this.assets=new Map,this.loaded=!1,this.onCreate=new s,this.onDelete=new s,this.onUpdate=new s}async getAssets(){if(!this.loaded){const s=await this.backend.getAssets();for(const t of s)this.assets.set(t.id,t)}return Array.from(this.assets.values())}async getAsset(s){return this.assets.get(s)??async function(s,e){t.has(s)||t.set(s,e(s));return t.get(s)}(s,(()=>this.backend.getAsset(s)))}}const t=new Map;
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- import { Asset, SceneData } from './model';
1
+ import { Asset, SceneData } from './model.js';
2
2
  export declare class RuntimeBackendService {
3
3
  private sceneStorage;
4
4
  private sceneBlobStorage;
@@ -1,4 +1,4 @@
1
- import{__awaiter as e}from"tslib";import{ObjectStorage as t}from"./storage/storage";export class RuntimeBackendService{constructor(e){this.sceneStorage=new t("scene"),this.sceneBlobStorage=new t("scene-blob"),this.assetStorage=new t("asset"),this.sceneStorage.setBasePath(e),this.sceneBlobStorage.setBasePath(e),this.assetStorage.setBasePath(e)}getAssets(){return this.assetStorage.getAll()}getAsset(e){return this.assetStorage.get(e)}getScenes(){return this.sceneStorage.getAll()}getScene(e){return this.sceneStorage.get(e)}getSceneData(t){return e(this,void 0,void 0,(function*(){const e=yield this.sceneBlobStorage.get(t);return null==e?void 0:e.data}))}}
1
+ import{ObjectStorage as e}from"./storage/storage.js";export class RuntimeBackendService{constructor(t){this.sceneStorage=new e("scene"),this.sceneBlobStorage=new e("scene-blob"),this.assetStorage=new e("asset"),this.sceneStorage.setBasePath(t),this.sceneBlobStorage.setBasePath(t),this.assetStorage.setBasePath(t)}getAssets(){return this.assetStorage.getAll()}getAsset(e){return this.assetStorage.get(e)}getScenes(){return this.sceneStorage.getAll()}getScene(e){return this.sceneStorage.get(e)}async getSceneData(e){const t=await this.sceneBlobStorage.get(e);return t?.data}}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- import { SceneDataProvider, SceneObject } from '../scene/materializer';
1
+ import { SceneDataProvider, SceneObject } from '../scene/materializer.js';
2
2
  import { BehaviorSubject } from 'rxjs';
3
3
  import { Matrix4 } from 'three';
4
4
  export declare class SceneDataService implements SceneDataProvider {
@@ -1,4 +1,4 @@
1
- import{BehaviorSubject as t}from"rxjs";import{Matrix4 as e,Vector3 as s,Quaternion as i,Euler as o}from"three";export class SceneDataService{constructor(){this.objects=[],this.callbacks=[],this.removeCallbacks=[],this.objectChange=new t([])}initiate(t,e=!1){var s;this.objects=t&&null!==(s=JSON.parse(t))&&void 0!==s?s:[];!this.objects.some((t=>"global_fog"===t.type))&&e&&this.objects.unshift({id:"auto-global-fog",name:"Global fog",type:"global_fog",position:[0,0,0],scale:[1,1,1],rotation:[0,0,0],collisionDetection:!1,fog:{type:"density",color:"#b8f8ff",density:.005,near:100,far:1e3}});this.objects.some((t=>"sky"===t.type))||this.objects.unshift({id:"auto-sky",name:"Sky",type:"sky",position:[0,0,0],scale:[1,1,1],rotation:[0,0,0],collisionDetection:!1,sky:{materialId:null}}),this.objectChange.next(this.objects)}removeOnUpdateCallback(t){this.callbacks.splice(this.callbacks.indexOf(t),1)}onUpdate(t){this.callbacks.push(t)}onRemove(t){this.removeCallbacks.push(t)}getObjects(){return this.objects}addObject(t){this.objects.push(t),this.callbacks.forEach((e=>e(t))),this.objectChange.next(this.objects)}updateObject(t){const e=this.findObjectById(t.id);e?(Object.assign(e,t),this.callbacks.forEach((e=>e(t)))):this.addObject(t),this.objectChange.next(this.objects)}findObjectById(t){const e=[...this.objects];for(;e.length>0;){const s=e.pop();if(s.id===t)return s;s.children&&e.push(...s.children)}}findAncestorsById(t){const e=this.findParentById(t);return null==e?[]:[e,...this.findAncestorsById(e.id)]}findParentById(t){return this._findParentById(t,this.objects)}_findParentById(t,e,s=null){return e.some((e=>e.id===t))?s:e.filter((t=>null!=t.children)).map((e=>this._findParentById(t,e.children,e))).find((t=>null!=t))}updateParent(t,n){var r,c;const l=this.findParentById(t.id);{const r=null!=n?this.getMatrixWorld(n).invert():(new e).identity();null!=l&&r.multiply(this.getMatrixWorld(l));const c=this.getLocalMatrix(t),a=r.multiply(c),h=new s,d=new i,b=new s;a.decompose(h,d,b),t.position=h.toArray(),t.rotation=(new o).setFromQuaternion(d).toArray(),t.scale=b.toArray()}this.removeRecursive(t.id,null!==(r=null==l?void 0:l.children)&&void 0!==r?r:this.objects),null!=n?(null!==(c=n.children)&&void 0!==c||(n.children=[]),n.children.push(t)):this.objects.push(t),this.objectChange.next(this.objects),this.callbacks.forEach((e=>e(t)))}getMatrixWorld(t){const e=this.findAncestorsById(t.id).reverse();e.push(t);const s=this.getLocalMatrix(e.shift());for(const t of e){const e=this.getLocalMatrix(t);s.multiply(e)}return s}getLocalMatrix(t){const n=new e,r=(new s).fromArray(t.position),c=(new i).setFromEuler((new o).fromArray(t.rotation)),l=(new s).fromArray(t.scale);return n.compose(r,c,l),n}removeObject(t){this.removeRecursive(t.id,this.objects),this.removeCallbacks.forEach((e=>e(t))),this.objectChange.next(this.objects)}removeRecursive(t,e){var s;const i=e.findIndex((e=>e.id===t));if(i>-1)e.splice(i,1);else for(const i of e)this.removeRecursive(t,null!==(s=i.children)&&void 0!==s?s:[])}save(){}serialize(){return JSON.stringify(this.objects)}}
1
+ import{BehaviorSubject as t}from"rxjs";import{Matrix4 as e,Vector3 as s,Quaternion as i,Euler as o}from"three";export class SceneDataService{constructor(){this.objects=[],this.callbacks=[],this.removeCallbacks=[],this.objectChange=new t([])}initiate(t,e=!1){this.objects=t?JSON.parse(t)??[]:[];!this.objects.some((t=>"global_fog"===t.type))&&e&&this.objects.unshift({id:"auto-global-fog",name:"Global fog",type:"global_fog",position:[0,0,0],scale:[1,1,1],rotation:[0,0,0],collisionDetection:!1,fog:{type:"density",color:"#b8f8ff",density:.005,near:100,far:1e3}});this.objects.some((t=>"sky"===t.type))||this.objects.unshift({id:"auto-sky",name:"Sky",type:"sky",position:[0,0,0],scale:[1,1,1],rotation:[0,0,0],collisionDetection:!1,sky:{materialId:null}}),this.objectChange.next(this.objects)}removeOnUpdateCallback(t){this.callbacks.splice(this.callbacks.indexOf(t),1)}onUpdate(t){this.callbacks.push(t)}onRemove(t){this.removeCallbacks.push(t)}getObjects(){return this.objects}addObject(t){this.objects.push(t),this.callbacks.forEach((e=>e(t))),this.objectChange.next(this.objects)}updateObject(t){const e=this.findObjectById(t.id);e?(Object.assign(e,t),this.callbacks.forEach((e=>e(t)))):this.addObject(t),this.objectChange.next(this.objects)}findObjectById(t){const e=[...this.objects];for(;e.length>0;){const s=e.pop();if(s.id===t)return s;s.children&&e.push(...s.children)}}findAncestorsById(t){const e=this.findParentById(t);return null==e?[]:[e,...this.findAncestorsById(e.id)]}findParentById(t){return this._findParentById(t,this.objects)}_findParentById(t,e,s=null){return e.some((e=>e.id===t))?s:e.filter((t=>null!=t.children)).map((e=>this._findParentById(t,e.children,e))).find((t=>null!=t))}updateParent(t,n){const r=this.findParentById(t.id);{const c=null!=n?this.getMatrixWorld(n).invert():(new e).identity();null!=r&&c.multiply(this.getMatrixWorld(r));const a=this.getLocalMatrix(t),l=c.multiply(a),h=new s,d=new i,b=new s;l.decompose(h,d,b),t.position=h.toArray(),t.rotation=(new o).setFromQuaternion(d).toArray(),t.scale=b.toArray()}this.removeRecursive(t.id,r?.children??this.objects),null!=n?(n.children??=[],n.children.push(t)):this.objects.push(t),this.objectChange.next(this.objects),this.callbacks.forEach((e=>e(t)))}getMatrixWorld(t){const e=this.findAncestorsById(t.id).reverse();e.push(t);const s=this.getLocalMatrix(e.shift());for(const t of e){const e=this.getLocalMatrix(t);s.multiply(e)}return s}getLocalMatrix(t){const n=new e,r=(new s).fromArray(t.position),c=(new i).setFromEuler((new o).fromArray(t.rotation)),a=(new s).fromArray(t.scale);return n.compose(r,c,a),n}removeObject(t){this.removeRecursive(t.id,this.objects),this.removeCallbacks.forEach((e=>e(t))),this.objectChange.next(this.objects)}removeRecursive(t,e){const s=e.findIndex((e=>e.id===t));if(s>-1)e.splice(s,1);else for(const s of e)this.removeRecursive(t,s.children??[])}save(){}serialize(){return JSON.stringify(this.objects)}}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- import{__awaiter as e}from"tslib";import{randomUUID as t}from"../../utils/uuid";import{pathJoin as i}from"../../utils/files";import{firstValueFrom as n,map as r,Subject as s,tap as o}from"rxjs";import{sleepDelay as a}from"../../utils/async";const d={},h={},l={};null==d.read&&window.require&&(Object.assign(d,window.require("fs")),Object.assign(h,d.promises),Object.assign(l,window.require("path")));const u=null!=d.existsSync;const c=/^[A-Z]:/;function p(...e){return 0===e.length?"":c.test(e[0])?l.join(...e):i(...e)}export class ObjectStorage{constructor(e,t){this.name=e,this.filePathFn=t,this.basePathUpdates=new s,this.basePath=this.basePathUpdates.pipe(r((e=>p(function(){if(u){const e="--path=",t=window.process.argv.find((t=>t.startsWith(e)));return t?t.substring(e.length):""}return""}(),e))),o((e=>{this.path=p(e,this.name),f(this.path)}))),this.loaded=n(this.basePath)}setBasePath(e){this.basePathUpdates.next(e)}getAll(){return e(this,void 0,void 0,(function*(){y(),yield this.loaded;const e=(yield h.readdir(this.path)).filter((e=>!/^[\._]/.test(e)));return(yield Promise.all(e.map((e=>h.readFile(p(this.path,e)))))).map((e=>JSON.parse(e.toString())))}))}get(t){var i;return e(this,void 0,void 0,(function*(){const e=yield this.loadIndex(),n=null!==(i=e[t])&&void 0!==i?i:Object.values(e).find((e=>e.name===t));if(null==n)return;const r=this.privateObjectPath(n);if(!u)return(yield fetch(r)).json();return(yield v(r))?JSON.parse((yield h.readFile(r)).toString()):null}))}save(t){return e(this,void 0,void 0,(function*(){return y(),yield this.loaded,yield h.writeFile(this.privateObjectPath(t),JSON.stringify(t,null,2)),yield this.updateIndex(),t}))}rename(t,i){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t),{name:i}),n=this.privateObjectPath(t),r=this.privateObjectPath(e);try{yield h.rename(n,r)}catch(e){console.error(e),console.warn("Rename failed, retrying",{currentPath:n,newPath:r}),yield a(400),yield h.rename(n,r)}return yield this.save(e),yield this.updateIndex(),e}))}delete(t){return e(this,void 0,void 0,(function*(){yield h.unlink(this.privateObjectPath(t)),this.updateIndex()}))}create(i){return e(this,void 0,void 0,(function*(){return y(),yield this.loaded,i.id=t(),yield h.writeFile(this.privateObjectPath(i),JSON.stringify(i,null,2)),yield this.updateIndex(),i}))}updateIndex(){var t;return e(this,void 0,void 0,(function*(){y();const e=yield this.getAll(),i={};for(const n of e)i[n.id]={id:n.id,name:null!==(t=n.name)&&void 0!==t?t:n.id,path:n.path};this.cachedIndex=i,u&&(yield h.writeFile(this.indexFilePath,JSON.stringify(i,null,2)))}))}get indexFilePath(){return p(this.path,"_meta.json")}loadIndex(){return e(this,void 0,void 0,(function*(){return null==this.cachedIndex&&(u?yield this.updateIndex():this.cachedIndex=yield(yield fetch(this.indexFilePath)).json()),this.cachedIndex}))}ensureResourceDir(){return e(this,void 0,void 0,(function*(){yield f(p(this.path+"-resources"))}))}saveFile(t,i){return e(this,void 0,void 0,(function*(){return y(),yield f(p(this.path+"-resources")),h.copyFile(i.path,p(this.path+"-resources",t.fileKey))}))}saveExtraFile(t,i){return e(this,void 0,void 0,(function*(){return y(),yield f(p(this.path+"-resources")),h.copyFile(t,p(this.path+"-resources",i))}))}getAssetPath(e){return window&&"function"==typeof window.require?window.require("path").join(this.path+"-resources",e.fileKey):p(this.path+"-resources",e.fileKey)}replaceFile(t,i){return e(this,void 0,void 0,(function*(){if(yield v(i))return h.copyFile(i,p(this.path+"-resources",t.fileKey));console.error("Failed to replace file using path "+i)}))}deleteFile(t){return e(this,void 0,void 0,(function*(){if(null==t)return;y();const e=p(this.path+"-resources",t);return(yield v(e))?h.unlink(e):void 0}))}privateObjectPath(e){var t;return this.filePathFn?p(this.path,this.filePathFn(e)):p(this.path,tokenizeName(null!==(t=e.name)&&void 0!==t?t:e.id)+".json")}}export function tokenizeName(e){return e.trim().replace(/\s/g,"_").replace(/[^a-z0-9_\-\.]/gi,"")}function f(t){return e(this,void 0,void 0,(function*(){u&&((yield v(t))||(yield h.mkdir(t,{recursive:!0})))}))}function v(e){return!!u&&new Promise((function(t,i){d.exists(e,(function(e){t(e)}))}))}function y(){if(!u)throw new Error("Must have direct access to filesystem")}
1
+ import{randomUUID as t}from"../../utils/uuid.js";import{pathJoin as e}from"../../utils/files.js";import{firstValueFrom as a,map as i,Subject as s,tap as n}from"rxjs";import{sleepDelay as r}from"../../utils/async.js";const h={},c={},o={};null==h.read&&window.require&&(Object.assign(h,window.require("fs")),Object.assign(c,h.promises),Object.assign(o,window.require("path")));const l=null!=h.existsSync;const u=/^[A-Z]:/;function d(...t){return 0===t.length?"":u.test(t[0])?o.join(...t):e(...t)}export class ObjectStorage{constructor(t,e){this.name=t,this.filePathFn=e,this.basePathUpdates=new s,this.basePath=this.basePathUpdates.pipe(i((t=>d(function(){if(l){const t="--path=",e=window.process.argv.find((e=>e.startsWith(t)));return e?e.substring(t.length):""}return""}(),t))),n((t=>{this.path=d(t,this.name),p(this.path)}))),this.loaded=a(this.basePath)}setBasePath(t){this.basePathUpdates.next(t)}async getAll(){if(l){await this.loaded,await p(this.path);const t=(await c.readdir(this.path)).filter((t=>!/^[\._]/.test(t)));return(await Promise.all(t.map((t=>c.readFile(d(this.path,t)))))).map((t=>JSON.parse(t.toString())))}const t=await this.loadIndex();return Promise.all(Object.keys(t).map((t=>this.get(t))))}async get(t){const e=await this.loadIndex(),a=e[t]??Object.values(e).find((e=>e.name===t));if(null==a)return;const i=this.privateObjectPath(a);if(!l)return(await fetch(i)).json();return await w(i)?JSON.parse((await c.readFile(i)).toString()):null}async save(t){return f(),await this.loaded,await c.writeFile(this.privateObjectPath(t),JSON.stringify(t,null,2)),await this.updateIndex(),t}async rename(t,e){const a={...t,name:e},i=this.privateObjectPath(t),s=this.privateObjectPath(a);try{await c.rename(i,s)}catch(t){console.error(t),console.warn("Rename failed, retrying",{currentPath:i,newPath:s}),await r(400),await c.rename(i,s)}return await this.save(a),await this.updateIndex(),a}async delete(t){await c.unlink(this.privateObjectPath(t)),this.updateIndex()}async create(e){return f(),await this.loaded,e.id=t(),await c.writeFile(this.privateObjectPath(e),JSON.stringify(e,null,2)),await this.updateIndex(),e}async updateIndex(){f();const t=await this.getAll(),e={};for(const a of t)e[a.id]={id:a.id,name:a.name??a.id,path:a.path};this.cachedIndex=e,l&&await c.writeFile(this.indexFilePath,JSON.stringify(e,null,2))}get indexFilePath(){return d(this.path,"_meta.json")}async loadIndex(){return null==this.cachedIndex&&(l?await this.updateIndex():this.cachedIndex=await(await fetch(this.indexFilePath)).json()),this.cachedIndex}async ensureResourceDir(){await p(d(this.path+"-resources"))}async saveFile(t,e){return f(),await p(d(this.path+"-resources")),c.copyFile(e.path,d(this.path+"-resources",t.fileKey))}async saveExtraFile(t,e){return f(),await p(d(this.path+"-resources")),c.copyFile(t,d(this.path+"-resources",e))}getAssetPath(t){return window&&"function"==typeof window.require?window.require("path").join(this.path+"-resources",t.fileKey):d(this.path+"-resources",t.fileKey)}async replaceFile(t,e){if(await w(e))return c.copyFile(e,d(this.path+"-resources",t.fileKey));console.error("Failed to replace file using path "+e)}async deleteFile(t){if(null==t)return;f();const e=d(this.path+"-resources",t);return await w(e)?c.unlink(e):void 0}privateObjectPath(t){return this.filePathFn?d(this.path,this.filePathFn(t)):d(this.path,tokenizeName(t.name??t.id)+".json")}}export function tokenizeName(t){return t.trim().replace(/\s/g,"_").replace(/[^a-z0-9_\-\.]/gi,"")}async function p(t){l&&(await w(t)||await c.mkdir(t,{recursive:!0}))}function w(t){return!!l&&new Promise((function(e,a){h.exists(t,(function(t){e(t)}))}))}function f(){if(!l)throw new Error("Must have direct access to filesystem")}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,2 +1,2 @@
1
- export * from './standard-shader';
2
- export * from './lambert-shader';
1
+ export * from './standard-shader.js';
2
+ export * from './lambert-shader.js';
@@ -1,4 +1,4 @@
1
- export*from"./standard-shader";export*from"./lambert-shader";
1
+ export*from"./standard-shader.js";export*from"./lambert-shader.js";
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,5 +1,5 @@
1
1
  import { Color, Material, Texture } from 'three';
2
- import { Shader } from "../shader";
2
+ import { Shader } from '../shader.js';
3
3
  export declare class LambertShader extends Shader {
4
4
  color?: Color;
5
5
  emissive?: Color;
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Color as i,Texture as a,MeshLambertMaterial as r}from"three";import{Shader as p}from"../shader";import{Parameter as o}from"../parameter";export class LambertShader extends p{build(){return new r({color:this.color,emissive:this.emissive,emissiveIntensity:this.emissiveIntensity,emissiveMap:this.emissiveMap,map:this.map,lightMap:this.lightMap,lightMapIntensity:this.lightMapIntensity,aoMap:this.aoMap,aoMapIntensity:this.aoMapIntensity,specularMap:this.specularMap,alphaMap:this.alphaMap,envMap:this.envMap,reflectivity:this.reflectivity,refractionRatio:this.refractionRatio})}}e([o(),t("design:type",i)],LambertShader.prototype,"color",void 0),e([o(),t("design:type",i)],LambertShader.prototype,"emissive",void 0),e([o({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"emissiveIntensity",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"emissiveMap",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"map",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"lightMap",void 0),e([o(),t("design:type",Number)],LambertShader.prototype,"lightMapIntensity",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"aoMap",void 0),e([o(),t("design:type",Number)],LambertShader.prototype,"aoMapIntensity",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"specularMap",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"alphaMap",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"envMap",void 0),e([o({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"reflectivity",void 0),e([o({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"refractionRatio",void 0);
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Color as i,Texture as a,MeshLambertMaterial as r}from"three";import{Shader as p}from"../shader.js";import{Parameter as o}from"../parameter.js";export class LambertShader extends p{build(){return new r({color:this.color,emissive:this.emissive,emissiveIntensity:this.emissiveIntensity,emissiveMap:this.emissiveMap,map:this.map,lightMap:this.lightMap,lightMapIntensity:this.lightMapIntensity,aoMap:this.aoMap,aoMapIntensity:this.aoMapIntensity,specularMap:this.specularMap,alphaMap:this.alphaMap,envMap:this.envMap,reflectivity:this.reflectivity,refractionRatio:this.refractionRatio})}}e([o(),t("design:type",i)],LambertShader.prototype,"color",void 0),e([o(),t("design:type",i)],LambertShader.prototype,"emissive",void 0),e([o({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"emissiveIntensity",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"emissiveMap",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"map",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"lightMap",void 0),e([o(),t("design:type",Number)],LambertShader.prototype,"lightMapIntensity",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"aoMap",void 0),e([o(),t("design:type",Number)],LambertShader.prototype,"aoMapIntensity",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"specularMap",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"alphaMap",void 0),e([o(),t("design:type",a)],LambertShader.prototype,"envMap",void 0),e([o({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"reflectivity",void 0),e([o({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"refractionRatio",void 0);
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,5 +1,5 @@
1
1
  import { Color, Material, Texture, Vector2 } from 'three';
2
- import { Shader } from "../shader";
2
+ import { Shader } from '../shader.js';
3
3
  export declare class StandardShader extends Shader {
4
4
  color: Color;
5
5
  roughness?: number;
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Color as a,MeshStandardMaterial as p,Texture as d,Vector2 as i}from"three";import{Shader as r}from"../shader";import{Parameter as s}from"../parameter";import{removeObjectUndefined as n}from"../../utils/collections";export class StandardShader extends r{build(){return new p(n({color:this.color,roughness:this.roughness,metalness:this.metalness,map:this.map,lightMap:this.lightMap,lightMapIntensity:this.lightMapIntensity,aoMap:this.aoMap,aoMapIntensity:this.aoMapIntensity,emissive:this.emissive,emissiveIntensity:this.emissiveIntensity,emissiveMap:this.emissiveMap,bumpMap:this.bumpMap,bumpScale:this.bumpScale,normalMap:this.normalMap,normalScale:this.normalScale,displacementMap:this.displacementMap,displacementScale:this.displacementScale,displacementBias:this.displacementBias,roughnessMap:this.roughnessMap,metalnessMap:this.metalnessMap,alphaMap:this.alphaMap,envMap:this.envMap,envMapIntensity:this.envMapIntensity,refractionRatio:this.refractionRatio}))}}e([s(),t("design:type",a)],StandardShader.prototype,"color",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"roughness",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"metalness",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"map",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"lightMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"lightMapIntensity",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"aoMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"aoMapIntensity",void 0),e([s(),t("design:type",a)],StandardShader.prototype,"emissive",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"emissiveIntensity",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"emissiveMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"bumpMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"bumpScale",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"normalMap",void 0),e([s(),t("design:type",i)],StandardShader.prototype,"normalScale",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"displacementMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"displacementScale",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"displacementBias",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"roughnessMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"metalnessMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"alphaMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"envMap",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"envMapIntensity",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"refractionRatio",void 0);
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Color as a,MeshStandardMaterial as p,Texture as d,Vector2 as i}from"three";import{Shader as r}from"../shader.js";import{Parameter as s}from"../parameter.js";import{removeObjectUndefined as n}from"../../utils/collections.js";export class StandardShader extends r{build(){return new p(n({color:this.color,roughness:this.roughness,metalness:this.metalness,map:this.map,lightMap:this.lightMap,lightMapIntensity:this.lightMapIntensity,aoMap:this.aoMap,aoMapIntensity:this.aoMapIntensity,emissive:this.emissive,emissiveIntensity:this.emissiveIntensity,emissiveMap:this.emissiveMap,bumpMap:this.bumpMap,bumpScale:this.bumpScale,normalMap:this.normalMap,normalScale:this.normalScale,displacementMap:this.displacementMap,displacementScale:this.displacementScale,displacementBias:this.displacementBias,roughnessMap:this.roughnessMap,metalnessMap:this.metalnessMap,alphaMap:this.alphaMap,envMap:this.envMap,envMapIntensity:this.envMapIntensity,refractionRatio:this.refractionRatio}))}}e([s(),t("design:type",a)],StandardShader.prototype,"color",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"roughness",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"metalness",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"map",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"lightMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"lightMapIntensity",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"aoMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"aoMapIntensity",void 0),e([s(),t("design:type",a)],StandardShader.prototype,"emissive",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"emissiveIntensity",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"emissiveMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"bumpMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"bumpScale",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"normalMap",void 0),e([s(),t("design:type",i)],StandardShader.prototype,"normalScale",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"displacementMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"displacementScale",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"displacementBias",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"roughnessMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"metalnessMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"alphaMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"envMap",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"envMapIntensity",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"refractionRatio",void 0);
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,3 +1,3 @@
1
- export * from './parameter';
2
- export * from './builtin';
3
- export * from './shader';
1
+ export * from './parameter.js';
2
+ export * from './builtin/index.js';
3
+ export * from './shader.js';
@@ -1,4 +1,4 @@
1
- export*from"./parameter";export*from"./builtin";export*from"./shader";
1
+ export*from"./parameter.js";export*from"./builtin/index.js";export*from"./shader.js";
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,9 +1,9 @@
1
1
  import 'reflect-metadata';
2
- import { Type } from '../utils/type';
3
- import { BaseActor } from '../gameplay/actors/actor';
2
+ import { Type } from '../utils/type.js';
3
+ import { BaseActor } from '../gameplay/actors/actor.js';
4
4
  import { Color, Euler, Material, Object3D, Texture, Vector2, Vector3, Vector4 } from 'three';
5
- import { BooleanNode, FloatNode, RgbNode, Sampler2DNode, Vec2Node, Vec3Node, Vec4Node } from '../shader-nodes';
6
- import { VisualEffect } from '../effects/vfx/vfx-param';
5
+ import { BooleanNode, FloatNode, RgbNode, Sampler2DNode, Vec2Node, Vec3Node, Vec4Node } from '../shader-nodes/index.js';
6
+ import { VisualEffect } from '../effects/vfx/vfx-param.js';
7
7
  export type ParameterType = Type<FloatNode | Number | Texture | Sampler2DNode | Boolean | BooleanNode | Vector2 | Vec2Node | Vector3 | Vec3Node | Vector4 | Vec4Node | Color | RgbNode | String | BaseActor | Euler | Object3D | Material | VisualEffect>;
8
8
  export type ParameterOption<T> = {
9
9
  name: string;
@@ -1,4 +1,4 @@
1
- import"reflect-metadata";import t,{decorateProperty as e}from"@plumier/reflect";import{ArrayMap as o}from"../utils/collections";Symbol("format");class r{constructor(t){this.options=t,this.isParameterDecorator=!0}}const n=new o;export function Parameter(t){return function(o,a,c){if(null!=o){n.push(o.constructor,{name:a,options:null!=t?t:{}});try{e(new r(t))(o,a,c)}catch(t){console.warn("Failed to decorate method ",o,a,c)}}}}export function extractShaderParameters(t){return n.get(t).map((({name:e,options:o})=>{var r;return{name:e,type:null!==(r=o.type)&&void 0!==r?r:Reflect.getMetadata("design:type",t.prototype,e),options:o}}))}
1
+ import"reflect-metadata";import{reflect as t,decorateProperty as e}from"@plumier/reflect";import{ArrayMap as o}from"../utils/collections.js";Symbol("format");class r{constructor(t){this.options=t,this.isParameterDecorator=!0}}const a=new o;export function Parameter(t){return function(o,n,c){if(null!=o){a.push(o.constructor,{name:n,options:t??{}});try{e(new r(t))(o,n,c)}catch(t){console.warn("Failed to decorate method ",o,n,c)}}}}export function extractShaderParameters(t){return a.get(t).map((({name:e,options:o})=>({name:e,type:o.type??Reflect.getMetadata("design:type",t.prototype,e),options:o})))}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,8 +1,8 @@
1
- import { BaseActor } from "../gameplay";
1
+ import { BaseActor } from '../gameplay/index.js';
2
2
  import { Material } from "three";
3
- import { RgbaNode, Mat4Node } from "../shader-nodes";
4
- import { Type } from "../utils/type";
5
- export * from './parameter';
3
+ import { RgbaNode, Mat4Node } from '../shader-nodes/index.js';
4
+ import { Type } from '../utils/type.js';
5
+ export * from './parameter.js';
6
6
  export declare abstract class Shader {
7
7
  abstract build(): Material;
8
8
  }
@@ -1,4 +1,4 @@
1
- import{NodeShaderMaterial as r}from"../shader-nodes";export*from"./parameter";export class Shader{}export class NodeShader{build(){return new r(Object.assign({transparent:!1},this.output()))}}
1
+ import{NodeShaderMaterial as r}from"../shader-nodes/index.js";export*from"./parameter.js";export class Shader{}export class NodeShader{build(){return new r({transparent:!1,...this.output()})}}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- import{Vec3ExpressionNode as t,attributes as r,dot as e,float as o,normalize as n,pow as c,saturate as i,uniforms as s,varyingAttributes as a,varyingVec3 as f,vec4 as p}from"three-shader-graph";import{fragmentLinearEyeDepth as u,linearEyeDepth as m}from"./depth";const d=s.modelMatrix.multiplyVec(p(r.position,1));export function fresnelEffect(s=1){const a=r.normal,f=new t("cameraPosition"),p=n(f.subtract(d.xyz())),u=o(1);return c(i(u.subtract(e(a,p))),o(s))}const h=o(1).subtract(m.subtract(u).divide(m));export function edgeDepthEffect(t=1){return c(h,o(t))}
1
+ import{Vec3ExpressionNode as t,attributes as r,dot as e,float as o,normalize as n,pow as c,saturate as i,uniforms as s,varyingAttributes as a,varyingVec3 as f,vec4 as p}from"three-shader-graph";import{fragmentLinearEyeDepth as u,linearEyeDepth as m}from"./depth.js";const d=s.modelMatrix.multiplyVec(p(r.position,1));export function fresnelEffect(s=1){const a=r.normal,f=new t("cameraPosition"),p=n(f.subtract(d.xyz())),u=o(1);return c(i(u.subtract(e(a,p))),o(s))}const h=o(1).subtract(m.subtract(u).divide(m));export function edgeDepthEffect(t=1){return c(h,o(t))}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,10 +1,10 @@
1
1
  export * from 'three-shader-graph';
2
- export { linearEyeDepth, fragmentLinearEyeDepth, depthSampler } from './depth';
3
- export { timeUniforms } from './time';
4
- export { particleUniforms } from './particle';
5
- export * from './layers';
6
- export * from './landscape';
7
- export * from './shapes';
8
- export * from './voronoi';
9
- export * from './effects';
10
- export * from './math';
2
+ export { linearEyeDepth, fragmentLinearEyeDepth, depthSampler } from './depth.js';
3
+ export { timeUniforms } from './time.js';
4
+ export { particleUniforms } from './particle.js';
5
+ export * from './layers.js';
6
+ export * from './landscape.js';
7
+ export * from './shapes.js';
8
+ export * from './voronoi.js';
9
+ export * from './effects.js';
10
+ export * from './math.js';
@@ -1,4 +1,4 @@
1
- export*from"three-shader-graph";export{linearEyeDepth,fragmentLinearEyeDepth,depthSampler}from"./depth";export{timeUniforms}from"./time";export{particleUniforms}from"./particle";export*from"./layers";export*from"./landscape";export*from"./shapes";export*from"./voronoi";export*from"./effects";export*from"./math";
1
+ export*from"three-shader-graph";export{linearEyeDepth,fragmentLinearEyeDepth,depthSampler}from"./depth.js";export{timeUniforms}from"./time.js";export{particleUniforms}from"./particle.js";export*from"./layers.js";export*from"./landscape.js";export*from"./shapes.js";export*from"./voronoi.js";export*from"./effects.js";export*from"./math.js";
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- import{float as e,uniforms as o,vec4 as r,attributes as t,varyingVec2 as a,AttributeVec3Node as i,varyingVec3 as l,SimplexNoiseNode as d,select as s,mix as n,smoothstep as c}from"three-shader-graph";export var LayerMixMode;!function(e){e[e.hard=0]="hard",e[e.soft=1]="soft"}(LayerMixMode||(LayerMixMode={}));const y={enableNoise:!0,noiseScale:e(.1),noiseAmount:e(.5),decay:.3,mode:LayerMixMode.soft},u=a(o.modelMatrix.multiplyVec(r(t.position,1)).xz()),m=l(new i("material")),p=[e(0),m.x(),m.y(),m.z()];export function mixColorsByLayer(o){const r=Object.assign(Object.assign({},y),o),t=e(r.noiseAmount).multiply(e(.1)),a=e(r.noiseScale),i=new d(u.multiplyScalar(a)).multiply(e(2)).subtract(e(1)).multiply(t),l=e(.5),m=r.enableNoise?l.add(i.multiply(e(.1))):l;if(r.mode==LayerMixMode.hard)return r.layerColors.reduce(((e,o,r)=>s(p[r].gt(m),o,e)));{const o=e(r.decay),t=e(.5),a=o.divide(e(2)),l=t.subtract(a),d=t.add(a);return r.layerColors.slice(0,p.length).reduce(((e,o,r)=>n(e,o,c(l,d,p[r].add(i)))))}}
1
+ import{float as e,uniforms as o,vec4 as r,attributes as t,varyingVec2 as a,AttributeVec3Node as i,varyingVec3 as l,SimplexNoiseNode as d,select as n,mix as s,smoothstep as y}from"three-shader-graph";export var LayerMixMode;!function(e){e[e.hard=0]="hard",e[e.soft=1]="soft"}(LayerMixMode||(LayerMixMode={}));const c={enableNoise:!0,noiseScale:e(.1),noiseAmount:e(.5),decay:.3,mode:LayerMixMode.soft},u=a(o.modelMatrix.multiplyVec(r(t.position,1)).xz()),m=l(new i("material")),p=[e(0),m.x(),m.y(),m.z()];export function mixColorsByLayer(o){const r={...c,...o},t=e(r.noiseAmount).multiply(e(.1)),a=e(r.noiseScale),i=new d(u.multiplyScalar(a)).multiply(e(2)).subtract(e(1)).multiply(t),l=e(.5),m=r.enableNoise?l.add(i.multiply(e(.1))):l;if(r.mode==LayerMixMode.hard)return r.layerColors.reduce(((e,o,r)=>n(p[r].gt(m),o,e)));{const o=e(r.decay),t=e(.5),a=o.divide(e(2)),l=t.subtract(a),d=t.add(a);return r.layerColors.slice(0,p.length).reduce(((e,o,r)=>s(e,o,y(l,d,p[r].add(i)))))}}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- import{__awaiter as t,__decorate as e}from"tslib";import"reflect-metadata";import{expect as o,test as s}from"vitest";import{Actor as a,ActorComponent as n,ActorFactory as i,BaseActor as c,Component as r,inject as l}from"../gameplay";import u,{Service as m}from"typedi";s("injecting without a service decorator",(()=>{class t{}const e=u.of("test");e.set({id:t,type:t});e.get(t)})),s("creating actors with non default container instance",(()=>t(void 0,void 0,void 0,(function*(){const t=new i(u.of("custom"),{inEditor:!1});u.set(i,t);const e=yield t.create(y);o(e.componentA.a.value).toBe(e.a.value),o(u.of("another").get(p).value).toBeGreaterThan(e.a.value)})))),s("injection with dynamically attached component using same container",(()=>t(void 0,void 0,void 0,(function*(){const t=new i(u.of("custom2"),{inEditor:!1});u.set(i,t);const e=yield t.create(g);o(e.componentA.a.value).toBe(e.a.value)}))));let d=class{};d=e([m()],d);let h=0,p=class{constructor(){this.name="a",this.value=h++,this.b=l(v)}};p=e([m()],p);let v=class{constructor(){this.name="b",this.value=h++}};v=e([m()],v);let f=class extends n{constructor(){super(...arguments),this.a=l(p)}};f=e([r()],f);let y=class extends c{constructor(){super(...arguments),this.a=l(p),this.componentA=this.attach(f)}};y=e([a()],y);let g=class extends c{constructor(){super(...arguments),this.a=l(p)}onInit(){this.componentA=this.attach(f)}};g=e([a()],g);
1
+ import{__decorate as t}from"tslib";import"reflect-metadata";import{expect as e,test as a}from"vitest";import{Actor as s,ActorComponent as o,ActorFactory as n,BaseActor as c,Component as i,inject as r}from"../gameplay/index.js";import{Container as l,Service as m}from"typedi";a("injecting without a service decorator",(()=>{class t{}const e=l.of("test");e.set({id:t,type:t});e.get(t)})),a("creating actors with non default container instance",(async()=>{const t=new n(l.of("custom"),{inEditor:!1});l.set(n,t);const a=await t.create(v);e(a.componentA.a.value).toBe(a.a.value),e(l.of("another").get(p).value).toBeGreaterThan(a.a.value)})),a("injection with dynamically attached component using same container",(async()=>{const t=new n(l.of("custom2"),{inEditor:!1});l.set(n,t);const a=await t.create(w);e(a.componentA.a.value).toBe(a.a.value)}));let u=class{};u=t([m()],u);let h=0,p=class{constructor(){this.name="a",this.value=h++,this.b=r(d)}};p=t([m()],p);let d=class{constructor(){this.name="b",this.value=h++}};d=t([m()],d);let f=class extends o{constructor(){super(...arguments),this.a=r(p)}};f=t([i()],f);let v=class extends c{constructor(){super(...arguments),this.a=r(p),this.componentA=this.attach(f)}};v=t([s()],v);let w=class extends c{constructor(){super(...arguments),this.a=r(p)}onInit(){this.componentA=this.attach(f)}};w=t([s()],w);
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- export function groupBy(t,e){const r=new Map;for(const s of null!=t?t:[]){const t=e(s);r.has(t)||r.set(t,[]),r.get(t).push(s)}return r}export function indexBy(t,e){const r=new Map;for(const s of null!=t?t:[])r.set(e(s),s);return r}export class DefaultMap{constructor(t){this.defaultValue=t,this.map=new Map}clear(){this.map.clear()}delete(t){return this.map.delete(t)}forEach(t,e){this.map.forEach(t)}getDefault(){return"function"==typeof this.defaultValue?this.defaultValue():JSON.parse(JSON.stringify(this.defaultValue))}get(t){return this.map.has(t)||this.map.set(t,this.getDefault()),this.map.get(t)}has(t){return!0}set(t,e){return this.map.set(t,e),this}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}Symbol.toStringTag;export class ArrayMap extends DefaultMap{constructor(){super((()=>[]))}push(t,e){this.get(t).push(e)}}export function partition(t,e){let r=[],s=[];for(const a of t)(e(a)?r:s).push(a);return[r,s]}export function removeObjectUndefined(t){for(const e of Object.keys(t))null==t[e]&&delete t[e];return t}
1
+ export function groupBy(t,e){const r=new Map;for(const s of t??[]){const t=e(s);r.has(t)||r.set(t,[]),r.get(t).push(s)}return r}export function indexBy(t,e){const r=new Map;for(const s of t??[])r.set(e(s),s);return r}export class DefaultMap{static{Symbol.toStringTag}constructor(t){this.defaultValue=t,this.map=new Map}clear(){this.map.clear()}delete(t){return this.map.delete(t)}forEach(t,e){this.map.forEach(t)}getDefault(){return"function"==typeof this.defaultValue?this.defaultValue():JSON.parse(JSON.stringify(this.defaultValue))}get(t){return this.map.has(t)||this.map.set(t,this.getDefault()),this.map.get(t)}has(t){return!0}set(t,e){return this.map.set(t,e),this}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}export class ArrayMap extends DefaultMap{constructor(){super((()=>[]))}push(t,e){this.get(t).push(e)}}export function partition(t,e){let r=[],s=[];for(const a of t)(e(a)?r:s).push(a);return[r,s]}export function removeObjectUndefined(t){for(const e of Object.keys(t))null==t[e]&&delete t[e];return t}
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -1,4 +1,4 @@
1
- import{depthUniformName as e}from"../../shader-nodes/depth";import{Mesh as r}from"three";import{Pass as t}from"three-stdlib";class i extends t{constructor(e,r,t,i){super(),this.scene=e,this.camera=r,this.depthMaterial=t,this.depthRenderTarget=i,this.needsSwap=!0}dispose(){}setSize(e,r){}render(t,i,s,a,n){if(this.renderToScreen)t.setRenderTarget(null),t.render(this.scene,this.camera);else{const s=[];this.scene.traverse((t=>{var i,a,n,d;t instanceof r&&t.visible&&((null===(a=null===(i=t.material)||void 0===i?void 0:i.userData)||void 0===a?void 0:a.water)||(null===(n=t.material)||void 0===n?void 0:n.uniforms)&&null!=(null===(d=t.material)||void 0===d?void 0:d.uniforms[e]))&&(t.visible=!1,s.push(t))})),this.scene.overrideMaterial=this.depthMaterial,t.setRenderTarget(this.depthRenderTarget),t.render(this.scene,this.camera),this.scene.overrideMaterial=null,s.forEach((e=>e.visible=!0)),t.setRenderTarget(i),t.clear(),t.render(this.scene,this.camera)}}}export{i as DepthPass};
1
+ import{depthUniformName as e}from"../../shader-nodes/depth.js";import{Mesh as r}from"three";import{Pass as t}from"three-stdlib";class s extends t{constructor(e,r,t,s){super(),this.scene=e,this.camera=r,this.depthMaterial=t,this.depthRenderTarget=s,this.needsSwap=!0}dispose(){}setSize(e,r){}render(t,s,i,a,n){if(this.renderToScreen)t.setRenderTarget(null),t.render(this.scene,this.camera);else{const i=[];this.scene.traverse((t=>{t instanceof r&&t.visible&&(t.material?.userData?.water||t.material?.uniforms&&null!=t.material?.uniforms[e])&&(t.visible=!1,i.push(t))})),this.scene.overrideMaterial=this.depthMaterial,t.setRenderTarget(this.depthRenderTarget),t.render(this.scene,this.camera),this.scene.overrideMaterial=null,i.forEach((e=>e.visible=!0)),t.setRenderTarget(s),t.clear(),t.render(this.scene,this.camera)}}}export{s as DepthPass};
2
2
  /*
3
3
  * Copyright (©) 2023. All rights reserved.
4
4
  * See the LICENSE.md file for details.
@@ -47,8 +47,8 @@ export class OutlinePass extends Pass {
47
47
  getOverlayMaterial(): ShaderMaterial;
48
48
  }
49
49
  export namespace OutlinePass {
50
- const BlurDirectionX: Vector2;
51
- const BlurDirectionY: Vector2;
50
+ let BlurDirectionX: Vector2;
51
+ let BlurDirectionY: Vector2;
52
52
  }
53
53
  import { Pass } from 'three-stdlib';
54
54
  import { Color } from 'three';
@@ -31,9 +31,9 @@ export class TransformControls extends Object3D<import("three").Event> {
31
31
  rotationAngle: any;
32
32
  pointerUp(pointer: any): void;
33
33
  dispose(): void;
34
- attach(object: any): TransformControls;
34
+ attach(object: any): this;
35
35
  object: any;
36
- detach(): TransformControls;
36
+ detach(): this;
37
37
  reset(): void;
38
38
  getRaycaster(): Raycaster;
39
39
  getMode(): any;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@hology/core",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
8
  "clean": "rimraf tsconfig.tsbuildinfo dist",
8
9
  "dev": "tsc --watch",
@@ -85,9 +86,7 @@
85
86
  "@dimforge/rapier3d-compat": "^0.11.2",
86
87
  "@plumier/reflect": "^1.1.0",
87
88
  "@types/three-nebula": "^10.0.3",
88
- "cannon-es": "^0.20.0",
89
- "cannon-es-debugger": "^1.0.0",
90
- "rxjs": "7.4.0",
89
+ "rxjs": "7.8.1",
91
90
  "stats.js": "^0.17.0",
92
91
  "three": "^0.139.0",
93
92
  "three-csm": "^3.2.0",
@@ -102,14 +101,14 @@
102
101
  "@babel/runtime": "^7.16.7",
103
102
  "@types/node": "^20.3.1",
104
103
  "@types/offscreencanvas": "^2019.7.0",
105
- "@types/three": "^0.139.0",
104
+ "@types/three": "0.139.0",
106
105
  "foreach-cli": "^1.8.1",
107
106
  "jsdom": "^22.1.0",
108
107
  "mkdirp": "^3.0.1",
109
108
  "reflect-metadata": "^0.1.13",
110
109
  "rimraf": "^4.1.1",
111
110
  "terser": "^5.25.0",
112
- "typescript": "~5.0.4",
113
- "vitest": "^0.34.2"
111
+ "typescript": "~5.4.4",
112
+ "vitest": "^1.0.0"
114
113
  }
115
114
  }