@hology/core 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/csm.d.ts +1 -1
- package/dist/csm.js +1 -1
- package/dist/effects/vfx/index.d.ts +2 -2
- package/dist/effects/vfx/index.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +14 -7
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-actor.d.ts +2 -2
- package/dist/effects/vfx/vfx-actor.js +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +3 -3
- package/dist/effects/vfx/vfx-asset.js +1 -1
- package/dist/effects/vfx/vfx-defs.d.ts +5 -2
- package/dist/effects/vfx/vfx-defs.js +1 -1
- package/dist/effects/vfx/vfx-materializer.d.ts +1 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/effects/vfx/vfx-param.d.ts +1 -1
- package/dist/gameplay/actors/actor.d.ts +1 -1
- package/dist/gameplay/actors/actor.js +1 -1
- package/dist/gameplay/actors/builtin/camera-actor.d.ts +3 -3
- package/dist/gameplay/actors/builtin/camera-actor.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -3
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts +4 -4
- package/dist/gameplay/actors/builtin/components/character/character-movement copy.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +4 -4
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
- package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +2 -2
- package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/scene-component.d.ts +1 -1
- package/dist/gameplay/actors/builtin/components/scene-component.js +1 -1
- package/dist/gameplay/actors/builtin/index.d.ts +4 -4
- package/dist/gameplay/actors/builtin/index.js +1 -1
- package/dist/gameplay/actors/builtin/positional-audio-actor.d.ts +6 -5
- package/dist/gameplay/actors/builtin/positional-audio-actor.js +1 -1
- package/dist/gameplay/actors/builtin/spawn-point.d.ts +3 -3
- package/dist/gameplay/actors/builtin/spawn-point.js +1 -1
- package/dist/gameplay/actors/builtin/trigger-volume.d.ts +4 -4
- package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
- package/dist/gameplay/actors/camera/camera-component.d.ts +2 -2
- package/dist/gameplay/actors/camera/camera-component.js +1 -1
- package/dist/gameplay/actors/camera/third-party-camera-component.d.ts +5 -5
- package/dist/gameplay/actors/camera/third-party-camera-component.js +1 -1
- package/dist/gameplay/actors/component.d.ts +1 -1
- package/dist/gameplay/actors/component.js +1 -1
- package/dist/gameplay/actors/factory.d.ts +3 -3
- package/dist/gameplay/actors/factory.js +1 -1
- package/dist/gameplay/actors/index.d.ts +10 -10
- package/dist/gameplay/actors/index.js +1 -1
- package/dist/gameplay/actors/internal/component-init.d.ts +2 -2
- package/dist/gameplay/actors/internal/component-init.js +1 -1
- package/dist/gameplay/actors/internal/container-map.d.ts +1 -1
- package/dist/gameplay/animation/anim-sm.js +1 -1
- package/dist/gameplay/index.d.ts +14 -13
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.d.ts +2 -2
- package/dist/gameplay/initiate.js +1 -1
- package/dist/gameplay/inject.js +1 -1
- package/dist/gameplay/input/index.d.ts +3 -3
- package/dist/gameplay/input/index.js +1 -1
- package/dist/gameplay/input/input-service.d.ts +1 -1
- package/dist/gameplay/input/input-service.js +1 -1
- package/dist/gameplay/input/input.js +1 -1
- package/dist/gameplay/services/asset-loader.d.ts +5 -5
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/physics-system.d.ts +5 -5
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/pointer-events.d.ts +58 -0
- package/dist/gameplay/services/pointer-events.js +5 -0
- package/dist/gameplay/services/render.d.ts +3 -3
- package/dist/gameplay/services/render.js +1 -1
- package/dist/gameplay/services/world.d.ts +2 -2
- package/dist/gameplay/services/world.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +2 -2
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/assets-provider.d.ts +1 -1
- package/dist/scene/bootstrap.d.ts +7 -7
- package/dist/scene/bootstrap.js +1 -1
- package/dist/scene/collision/collision-shape-import.d.ts +1 -1
- package/dist/scene/collision/collision-shape-import.js +1 -1
- package/dist/scene/landscape/landscape-manager.d.ts +6 -6
- package/dist/scene/landscape/landscape-manager.js +1 -1
- package/dist/scene/landscape/landscape.js +1 -1
- package/dist/scene/landscape/utils.d.ts +1 -1
- package/dist/scene/landscape/utils.js +1 -1
- package/dist/scene/materializer.d.ts +10 -10
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/materials/grass-foliage.d.ts +2 -2
- package/dist/scene/materials/grass-foliage.js +1 -1
- package/dist/scene/materials/grass.d.ts +1 -1
- package/dist/scene/materials/grass.js +1 -1
- package/dist/scene/materials/water.d.ts +1 -1
- package/dist/scene/materials/water.js +1 -1
- package/dist/scene/model.d.ts +5 -5
- package/dist/scene/objects/shapes.d.ts +3 -3
- package/dist/scene/objects/shapes.js +1 -1
- package/dist/scene/runtime-asset-service.d.ts +3 -3
- package/dist/scene/runtime-asset-service.js +1 -1
- package/dist/scene/runtime-backend-service.d.ts +1 -1
- package/dist/scene/runtime-backend-service.js +1 -1
- package/dist/scene/scene-data-service.d.ts +1 -1
- package/dist/scene/scene-data-service.js +1 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/index.d.ts +2 -2
- package/dist/shader/builtin/index.js +1 -1
- package/dist/shader/builtin/lambert-shader.d.ts +1 -1
- package/dist/shader/builtin/lambert-shader.js +1 -1
- package/dist/shader/builtin/standard-shader.d.ts +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/index.d.ts +3 -3
- package/dist/shader/index.js +1 -1
- package/dist/shader/parameter.d.ts +4 -4
- package/dist/shader/parameter.js +1 -1
- package/dist/shader/shader.d.ts +4 -4
- package/dist/shader/shader.js +1 -1
- package/dist/shader-nodes/effects.js +1 -1
- package/dist/shader-nodes/index.d.ts +9 -9
- package/dist/shader-nodes/index.js +1 -1
- package/dist/shader-nodes/layers.js +1 -1
- package/dist/test/injection.test.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/three/depth-pass.js +1 -1
- package/dist/utils/three/outline-pass.d.ts +2 -2
- package/dist/utils/three/transform-controls.d.ts +2 -2
- package/package.json +6 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cannon/CannonUtils.d.ts +0 -17
- package/dist/utils/cannon/CannonUtils.js +0 -5
- package/dist/utils/cannon/three-to-cannon/ConvexHull.d.ts +0 -47
- package/dist/utils/cannon/three-to-cannon/ConvexHull.js +0 -5
- package/dist/utils/cannon/three-to-cannon/index.d.ts +0 -63
- package/dist/utils/cannon/three-to-cannon/index.js +0 -5
- package/dist/utils/cannon/three-to-cannon/utils.d.ts +0 -9
- package/dist/utils/cannon/three-to-cannon/utils.js +0 -5
@@ -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){
|
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.
|
package/dist/scene/model.d.ts
CHANGED
@@ -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
|
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,7 +1,7 @@
|
|
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;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{
|
1
|
+
import{Subject as s}from"rxjs";export class RuntimeAssetsService{constructor(e){this.backend=e,this.assets=new Map,this.onCreate=new s,this.onDelete=new s,this.onUpdate=new s}async getAssets(){return Array.from(this.assets.values())}async getAsset(s){return this.assets.get(s)??async function(s,t){e.has(s)||e.set(s,t(s));return e.get(s)}(s,(()=>this.backend.getAsset(s)))}}const e=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{
|
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){
|
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{
|
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(){f(),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())))}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
|
-
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,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.
|
package/dist/shader/index.d.ts
CHANGED
@@ -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';
|
package/dist/shader/index.js
CHANGED
@@ -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;
|
package/dist/shader/parameter.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import"reflect-metadata";import t,
|
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.
|
package/dist/shader/shader.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import { BaseActor } from
|
1
|
+
import { BaseActor } from '../gameplay/index.js';
|
2
2
|
import { Material } from "three";
|
3
|
-
import { RgbaNode, Mat4Node } from
|
4
|
-
import { Type } from
|
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
|
}
|
package/dist/shader/shader.js
CHANGED
@@ -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(
|
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
|
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{
|
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
|
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
|
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
|
-
|
51
|
-
|
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):
|
34
|
+
attach(object: any): this;
|
35
35
|
object: any;
|
36
|
-
detach():
|
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.
|
3
|
+
"version": "0.0.33",
|
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
|
-
"
|
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": "
|
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.
|
113
|
-
"vitest": "^0.
|
111
|
+
"typescript": "~5.4.4",
|
112
|
+
"vitest": "^1.0.0"
|
114
113
|
}
|
115
114
|
}
|