@hology/core 0.0.191 → 0.0.193
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effects/sequence/sequence-actor.d.ts +4 -0
- package/dist/effects/sequence/sequence-actor.js +1 -1
- package/dist/effects/sequence/sequence-data.d.ts +5 -0
- package/dist/effects/sequence/sequence-data.js +1 -1
- package/dist/effects/sequence/sequence-player.d.ts +3 -0
- package/dist/effects/sequence/sequence-player.js +1 -1
- package/dist/effects/vfx/behaviours.d.ts +7 -0
- package/dist/effects/vfx/behaviours.js +1 -1
- package/dist/effects/vfx/index.d.ts +2 -0
- package/dist/effects/vfx/index.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +6 -4
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-actor.d.ts +10 -1
- package/dist/effects/vfx/vfx-actor.js +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +12 -0
- package/dist/effects/vfx/vfx-asset.js +1 -1
- package/dist/effects/vfx/vfx-binding-runtime.d.ts +42 -0
- package/dist/effects/vfx/vfx-binding-runtime.js +4 -0
- package/dist/effects/vfx/vfx-defs.d.ts +58 -3
- package/dist/effects/vfx/vfx-defs.js +1 -1
- package/dist/effects/vfx/vfx-input-runtime.d.ts +17 -0
- package/dist/effects/vfx/vfx-input-runtime.js +4 -0
- package/dist/effects/vfx/vfx-materializer.d.ts +2 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/effects/vfx/vfx-param.d.ts +3 -1
- package/dist/effects/vfx/vfx-param.js +1 -1
- package/dist/effects/vfx/vfx-service.d.ts +6 -2
- package/dist/effects/vfx/vfx-service.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -0
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
- package/dist/gameplay/services/asset-loader.d.ts +3 -0
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/render.d.ts +12 -0
- package/dist/gameplay/services/render.js +1 -1
- package/dist/rendering.d.ts +2 -0
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +1 -0
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/collision/collision-shape-import.js +1 -1
- package/dist/scene/collision/collision-shape.d.ts +5 -4
- package/dist/scene/collision/collision-shape.js +1 -1
- package/dist/scene/materializer.d.ts +4 -0
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/model.d.ts +53 -2
- package/dist/scene/storage/storage.d.ts +6 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/decal-standard-shader.d.ts +1 -1
- package/dist/shader/builtin/lambert-shader.js +1 -1
- package/dist/shader/builtin/standard-shader.d.ts +8 -6
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/builtin/toon-shader.js +1 -1
- package/dist/shader/parameter.d.ts +6 -0
- package/dist/shader-nodes/time.d.ts +1 -0
- package/dist/shader-nodes/time.js +1 -1
- package/dist/test/collision-shape-import.test.d.ts +2 -0
- package/dist/test/collision-shape-import.test.js +4 -0
- package/dist/test/vfx-input-bindings.test.d.ts +2 -0
- package/dist/test/vfx-input-bindings.test.js +4 -0
- package/dist/utils/obb-utils.d.ts +12 -0
- package/dist/utils/obb-utils.js +4 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as e,__metadata as a}from"tslib";import{Color as t,MeshStandardMaterial as n,Texture as r,Vector2 as i}from"three";import{Shader as p}from"../shader.js";import{Parameter as s}from"../parameter.js";import{removeObjectUndefined as d}from"../../utils/collections.js";const o=new r;export class StandardShader extends p{constructor(){super(...arguments),this.color=new t("#FFFFFF"),this.opacity=1,this.roughness=1,this.metalness=0,this.normalScale=new i(1,1),this.heightMap=o,this.vertexColor=!1}build(){const e=(null!=this.map||null!=this.normalMap)&&null!=this.heightMap&&this.heightMap!=o&&0!==this.heightScale;return new(e?ParallaxStandardMaterial:n)(d({color:this.color,vertexColors:this.vertexColor,opacity:this.opacity,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?{heightMap:this.heightMap,heightScale:this.heightScale}:{}}))}}e([s(),a("design:type",t)],StandardShader.prototype,"color",void 0),e([s({label:"Color Map"}),a("design:type",r)],StandardShader.prototype,"map",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"opacity",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"alphaMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"roughness",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"roughnessMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"metalness",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"metalnessMap",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"lightMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"lightMapIntensity",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"aoMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"aoMapIntensity",void 0),e([s(),a("design:type",t)],StandardShader.prototype,"emissive",void 0),e([s({range:[0,10]}),a("design:type",Number)],StandardShader.prototype,"emissiveIntensity",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"emissiveMap",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"bumpMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"bumpScale",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"normalMap",void 0),e([s(),a("design:type",i)],StandardShader.prototype,"normalScale",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"displacementMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"displacementScale",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"displacementBias",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"envMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"envMapIntensity",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"refractionRatio",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"heightMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"heightScale",void 0),e([s(),a("design:type",Boolean)],StandardShader.prototype,"vertexColor",void 0);export var ParallaxType;!function(e){e[e.none=0]="none",e[e.offset=1]="offset",e[e.pom=2]="pom"}(ParallaxType||(ParallaxType={}));export class ParallaxStandardMaterial extends n{constructor(e={}){super(e),e.heightMap&&(this.heightMap=e.heightMap),this.heightScale=e.heightScale??.05,this.parallaxType=e.parallaxType??ParallaxType.pom,this.minLayers=e.minLayers??10,this.maxLayers=e.maxLayers??32}onBeforeCompile(e){e.uniforms.heightMap={value:this.heightMap},e.uniforms.heightScale={value:this.heightScale},e.uniforms.minLayers={value:this.minLayers},e.uniforms.maxLayers={value:this.maxLayers},e.uniforms.parallaxType={value:this.parallaxType},e.vertexTangents=!0,e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>","\n #include <uv_pars_vertex>\n "),e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","\n #include <begin_vertex>\n "),e.fragmentShader=e.fragmentShader.replace("#include <uv_pars_fragment>","\n #include <uv_pars_fragment>\n uniform sampler2D heightMap;\n uniform float heightScale;\n uniform int minLayers;\n uniform int maxLayers;\n uniform int parallaxType;\n\n vec2 parallaxOffset(vec2 uv, vec3 viewDir, vec3 normal) {\n // Compute TBN in fragment shader using screen-space derivatives\n vec3 dp1 = dFdx(-vViewPosition);\n vec3 dp2 = dFdy(-vViewPosition);\n vec2 duv1 = dFdx(uv);\n vec2 duv2 = dFdy(uv);\n \n vec3 dp2perp = cross(dp2, normal);\n vec3 dp1perp = cross(normal, dp1);\n vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n \n float invmax = inversesqrt(max(dot(T,T), dot(B,B)));\n mat3 tbn = mat3(T * invmax, B * invmax, normal);\n vec3 viewDirTS = -viewDir * tbn;\n\n float h = texture(heightMap, uv).r;\n return uv - (viewDirTS.xy / viewDirTS.z) * (h * heightScale);\n }\n\n vec2 parallaxOcclusion2(vec2 uv, vec3 viewDir, vec3 normal) {\n // Compute TBN in fragment shader using screen-space derivatives\n vec3 dp1 = dFdx(-vViewPosition);\n vec3 dp2 = dFdy(-vViewPosition);\n vec2 duv1 = dFdx(uv);\n vec2 duv2 = dFdy(uv);\n \n vec3 dp2perp = cross(dp2, normal);\n vec3 dp1perp = cross(normal, dp1);\n vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n \n float invmax = inversesqrt(max(dot(T,T), dot(B,B)));\n mat3 tbn = mat3(T * invmax, B * invmax, normal);\n vec3 vv = -viewDir * tbn;\n\n float parallaxLimit = -length(vv.xy) / vv.z;\n parallaxLimit *= heightScale;\n\n vec2 vOffsetDir = normalize(vv.xy);\n vec2 vMaxOffset = vOffsetDir * parallaxLimit;\n\n float factor = pow(1.0 - abs(vv.z), 2.0);\n float nNumSamples = mix(float(minLayers), float(maxLayers), factor);\n float fStepSize = 1.0 / nNumSamples;\n\n float fCurrRayHeight = 1.0;\n vec2 vCurrOffset = vec2(0.0);\n vec2 vLastOffset = vec2(0.0);\n float fLastSampledHeight = 1.0;\n float fCurrSampledHeight = 1.0;\n\n for (int nCurrSample = 0; nCurrSample < 128; nCurrSample++) {\n if (float(nCurrSample) > nNumSamples) break;\n\n fCurrSampledHeight = texture2D(heightMap, uv + vCurrOffset).r;\n if (fCurrSampledHeight > fCurrRayHeight) {\n float delta1 = fCurrSampledHeight - fCurrRayHeight;\n float delta2 = (fCurrRayHeight + fStepSize) - fLastSampledHeight;\n float ratio = delta1 / (delta1 + delta2);\n vCurrOffset = ratio * vLastOffset + (1.0 - ratio) * vCurrOffset;\n break;\n } else {\n fCurrRayHeight -= fStepSize;\n vLastOffset = vCurrOffset;\n vCurrOffset += fStepSize * vMaxOffset;\n fLastSampledHeight = fCurrSampledHeight;\n }\n }\n\n return uv + vCurrOffset;\n }\n "),e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>","\n vec3 pomViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n vec2 uvPOM = vMapUv ;\n if (parallaxType == 1) {\n uvPOM = parallaxOffset(vMapUv, pomViewDir, vNormal);\n } else if (parallaxType == 2) {\n uvPOM = parallaxOcclusion2(vMapUv, pomViewDir, vNormal);\n }\n\n vec4 texelColor = texture2D(map, uvPOM);\n diffuseColor *= texelColor;\n "),e.fragmentShader=e.fragmentShader.replace("#include <normal_fragment_maps>","\n #ifdef USE_NORMALMAP\n // RE-COMPUTE TBN for normal mapping consistency\n vec3 dp1 = dFdx(-vViewPosition);\n vec3 dp2 = dFdy(-vViewPosition);\n vec2 duv1 = dFdx(uvPOM);\n vec2 duv2 = dFdy(uvPOM);\n vec3 dp2perp = cross(dp2, vNormal);\n vec3 dp1perp = cross(vNormal, dp1);\n vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n float invmax = inversesqrt(max(dot(T,T), dot(B,B)));\n mat3 localTBN = mat3(T * invmax, B * invmax, vNormal);\n\n vec3 mapN = texture2D(normalMap, uvPOM).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( localTBN * mapN );\n #endif\n "),e.fragmentShader=e.fragmentShader.replace("#include <roughnessmap_fragment>","\n float roughnessFactor = roughness;\n #ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, uvPOM );\n // reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n roughnessFactor *= texelRoughness.g;\n #endif\n "),e.fragmentShader=e.fragmentShader.replace("#include <metalnesssmap_fragment>","\n float metalnessFactor = metalness;\n #ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, uvPOM );\n // reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n metalnessFactor *= texelMetalness.b;\n #endif\n "),e.fragmentShader=e.fragmentShader.replace("#include <aomap_fragment>","\n #ifdef USE_AOMAP\n\n // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n float ambientOcclusion = ( texture2D( aoMap, uvPOM ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\n #endif\n\n #endif\n "),this.userData.shader=e}clone(){const e=super.clone();return e.heightMap=this.heightMap,e.heightScale=this.heightScale,e.parallaxType=this.parallaxType,e.minLayers=this.minLayers,e.maxLayers=this.maxLayers,e}}/*
|
|
1
|
+
import{__decorate as e,__metadata as a}from"tslib";import{Color as t,MeshStandardMaterial as n,Texture as r,Vector2 as i}from"three";import{Shader as o}from"../shader.js";import{Parameter as s}from"../parameter.js";import{removeObjectUndefined as p}from"../../utils/collections.js";import*as d from"three";const l=new r;export class StandardShader extends o{constructor(){super(...arguments),this.color=new t("#FFFFFF"),this.opacity=1,this.roughness=1,this.metalness=0,this.normalScale=new i(1,1),this.sheen=0,this.sheenColor=new t("#FFFFFF"),this.sheenRoughness=.5,this.anisotropy=0,this.heightMap=l,this.vertexColor=!1}build(){const e=this.sheen>0,a=this.anisotropy>0,t=a||e,r=(null!=this.map||null!=this.normalMap)&&null!=this.heightMap&&this.heightMap!=l&&0!==this.heightScale,i=r?ParallaxStandardMaterial:t?d.MeshPhysicalMaterial:n;this.map,null!=this.normalMap&&(this.normalMap.colorSpace=d.LinearSRGBColorSpace),null!=this.metalnessMap&&(this.metalnessMap.colorSpace=d.LinearSRGBColorSpace),null!=this.roughnessMap&&(this.roughnessMap.colorSpace=d.LinearSRGBColorSpace),null!=this.aoMap&&(this.aoMap.colorSpace=d.LinearSRGBColorSpace),null!=this.heightMap&&(this.heightMap.colorSpace=d.NoColorSpace),this.emissiveMap,null!=this.alphaMap&&(this.alphaMap.colorSpace=d.LinearSRGBColorSpace),null!=this.lightMap&&(this.lightMap.colorSpace=d.LinearSRGBColorSpace);return new i(p({color:this.color,vertexColors:this.vertexColor,opacity:this.opacity,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,normalMap:this.normalMap,normalScale:this.normalScale,sheen:e?this.sheen:void 0,sheenColor:e?this.sheenColor:void 0,sheenColorMap:e?this.sheenColorMap:void 0,sheenRoughness:e?this.sheenRoughness:void 0,sheenRoughnessMap:e?this.sheenRoughnessMap:void 0,anisotropy:a?this.anisotropy:void 0,anisotropyMap:a?this.anisotropyMap:void 0,anisotropyRotation:a?this.anisotropyRotation:void 0,roughnessMap:this.roughnessMap,metalnessMap:this.metalnessMap,alphaMap:this.alphaMap,envMap:this.envMap,envMapIntensity:this.envMapIntensity,...r?{heightMap:this.heightMap,heightScale:this.heightScale}:{}}))}}e([s(),a("design:type",t)],StandardShader.prototype,"color",void 0),e([s({label:"Color Map"}),a("design:type",r)],StandardShader.prototype,"map",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"opacity",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"alphaMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"roughness",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"roughnessMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"metalness",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"metalnessMap",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"lightMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"lightMapIntensity",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"aoMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"aoMapIntensity",void 0),e([s(),a("design:type",t)],StandardShader.prototype,"emissive",void 0),e([s({range:[0,10]}),a("design:type",Number)],StandardShader.prototype,"emissiveIntensity",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"emissiveMap",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"normalMap",void 0),e([s(),a("design:type",i)],StandardShader.prototype,"normalScale",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"sheen",void 0),e([s(),a("design:type",t)],StandardShader.prototype,"sheenColor",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"sheenColorMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"sheenRoughness",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"sheenRoughnessMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"anisotropyRotation",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"anisotropyMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"anisotropy",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"envMap",void 0),e([s({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"envMapIntensity",void 0),e([s(),a("design:type",r)],StandardShader.prototype,"heightMap",void 0),e([s(),a("design:type",Number)],StandardShader.prototype,"heightScale",void 0),e([s(),a("design:type",Boolean)],StandardShader.prototype,"vertexColor",void 0);export var ParallaxType;!function(e){e[e.none=0]="none",e[e.offset=1]="offset",e[e.pom=2]="pom"}(ParallaxType||(ParallaxType={}));export class ParallaxStandardMaterial extends n{constructor(e={}){super(e),e.heightMap&&(this.heightMap=e.heightMap),this.heightScale=e.heightScale??.05,this.parallaxType=e.parallaxType??ParallaxType.pom,this.minLayers=e.minLayers??10,this.maxLayers=e.maxLayers??32}onBeforeCompile(e){e.uniforms.heightMap={value:this.heightMap},e.uniforms.heightScale={value:this.heightScale},e.uniforms.minLayers={value:this.minLayers},e.uniforms.maxLayers={value:this.maxLayers},e.uniforms.parallaxType={value:this.parallaxType},e.vertexTangents=!0,e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>","\n #include <uv_pars_vertex>\n "),e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","\n #include <begin_vertex>\n "),e.fragmentShader=e.fragmentShader.replace("#include <uv_pars_fragment>","\n #include <uv_pars_fragment>\n uniform sampler2D heightMap;\n uniform float heightScale;\n uniform int minLayers;\n uniform int maxLayers;\n uniform int parallaxType;\n\n vec2 parallaxOffset(vec2 uv, vec3 viewDir, vec3 normal) {\n // Compute TBN in fragment shader using screen-space derivatives\n vec3 dp1 = dFdx(-vViewPosition);\n vec3 dp2 = dFdy(-vViewPosition);\n vec2 duv1 = dFdx(uv);\n vec2 duv2 = dFdy(uv);\n \n vec3 dp2perp = cross(dp2, normal);\n vec3 dp1perp = cross(normal, dp1);\n vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n \n float invmax = inversesqrt(max(dot(T,T), dot(B,B)));\n mat3 tbn = mat3(T * invmax, B * invmax, normal);\n vec3 viewDirTS = -viewDir * tbn;\n\n float h = texture(heightMap, uv).r;\n return uv - (viewDirTS.xy / viewDirTS.z) * (h * heightScale);\n }\n\n vec2 parallaxOcclusion2(vec2 uv, vec3 viewDir, vec3 normal) {\n // Compute TBN in fragment shader using screen-space derivatives\n vec3 dp1 = dFdx(-vViewPosition);\n vec3 dp2 = dFdy(-vViewPosition);\n vec2 duv1 = dFdx(uv);\n vec2 duv2 = dFdy(uv);\n \n vec3 dp2perp = cross(dp2, normal);\n vec3 dp1perp = cross(normal, dp1);\n vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n \n float invmax = inversesqrt(max(dot(T,T), dot(B,B)));\n mat3 tbn = mat3(T * invmax, B * invmax, normal);\n vec3 vv = -viewDir * tbn;\n\n float parallaxLimit = -length(vv.xy) / vv.z;\n parallaxLimit *= heightScale;\n\n vec2 vOffsetDir = normalize(vv.xy);\n vec2 vMaxOffset = vOffsetDir * parallaxLimit;\n\n float factor = pow(1.0 - abs(vv.z), 2.0);\n float nNumSamples = mix(float(minLayers), float(maxLayers), factor);\n float fStepSize = 1.0 / nNumSamples;\n\n float fCurrRayHeight = 1.0;\n vec2 vCurrOffset = vec2(0.0);\n vec2 vLastOffset = vec2(0.0);\n float fLastSampledHeight = 1.0;\n float fCurrSampledHeight = 1.0;\n\n for (int nCurrSample = 0; nCurrSample < 128; nCurrSample++) {\n if (float(nCurrSample) > nNumSamples) break;\n\n fCurrSampledHeight = texture2D(heightMap, uv + vCurrOffset).r;\n if (fCurrSampledHeight > fCurrRayHeight) {\n float delta1 = fCurrSampledHeight - fCurrRayHeight;\n float delta2 = (fCurrRayHeight + fStepSize) - fLastSampledHeight;\n float ratio = delta1 / (delta1 + delta2);\n vCurrOffset = ratio * vLastOffset + (1.0 - ratio) * vCurrOffset;\n break;\n } else {\n fCurrRayHeight -= fStepSize;\n vLastOffset = vCurrOffset;\n vCurrOffset += fStepSize * vMaxOffset;\n fLastSampledHeight = fCurrSampledHeight;\n }\n }\n\n return uv + vCurrOffset;\n }\n "),e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>","\n vec3 pomViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n vec2 uvPOM = vMapUv ;\n if (parallaxType == 1) {\n uvPOM = parallaxOffset(vMapUv, pomViewDir, vNormal);\n } else if (parallaxType == 2) {\n uvPOM = parallaxOcclusion2(vMapUv, pomViewDir, vNormal);\n }\n\n vec4 texelColor = texture2D(map, uvPOM);\n diffuseColor *= texelColor;\n "),e.fragmentShader=e.fragmentShader.replace("#include <normal_fragment_maps>","\n #ifdef USE_NORMALMAP\n // RE-COMPUTE TBN for normal mapping consistency\n vec3 dp1 = dFdx(-vViewPosition);\n vec3 dp2 = dFdy(-vViewPosition);\n vec2 duv1 = dFdx(uvPOM);\n vec2 duv2 = dFdy(uvPOM);\n vec3 dp2perp = cross(dp2, vNormal);\n vec3 dp1perp = cross(vNormal, dp1);\n vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n float invmax = inversesqrt(max(dot(T,T), dot(B,B)));\n mat3 localTBN = mat3(T * invmax, B * invmax, vNormal);\n\n vec3 mapN = texture2D(normalMap, uvPOM).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( localTBN * mapN );\n #endif\n "),e.fragmentShader=e.fragmentShader.replace("#include <roughnessmap_fragment>","\n float roughnessFactor = roughness;\n #ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, uvPOM );\n // reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n roughnessFactor *= texelRoughness.g;\n #endif\n "),e.fragmentShader=e.fragmentShader.replace("#include <metalnesssmap_fragment>","\n float metalnessFactor = metalness;\n #ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, uvPOM );\n // reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n metalnessFactor *= texelMetalness.b;\n #endif\n "),e.fragmentShader=e.fragmentShader.replace("#include <aomap_fragment>","\n #ifdef USE_AOMAP\n\n // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n float ambientOcclusion = ( texture2D( aoMap, uvPOM ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\n #endif\n\n #endif\n "),this.userData.shader=e}clone(){const e=super.clone();return e.heightMap=this.heightMap,e.heightScale=this.heightScale,e.parallaxType=this.parallaxType,e.minLayers=this.minLayers,e.maxLayers=this.maxLayers,e}}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as e,__metadata as t}from"tslib";import{Color as o,DataTexture as i,MeshToonMaterial as p,RedFormat as
|
|
1
|
+
import{__decorate as e,__metadata as t}from"tslib";import{Color as o,DataTexture as i,MeshToonMaterial as p,RedFormat as a,Texture as r,Vector2 as s}from"three";import{removeObjectUndefined as n}from"../../utils/collections.js";import{Parameter as l}from"../parameter.js";import{Shader as h}from"../shader.js";import*as d from"three";export class ToonShader extends h{constructor(){super(...arguments),this.color=new o("#FFFFFF"),this.opacity=1,this.intensity=1,this.lightSteps=[],this.normalScale=new s(1,1),this.vertexColor=!1}build(){let e;if(null!=this.map&&(this.map.colorSpace=d.SRGBColorSpace),null!=this.normalMap&&(this.normalMap.colorSpace=d.LinearSRGBColorSpace),null!=this.aoMap&&(this.aoMap.colorSpace=d.LinearSRGBColorSpace),null!=this.emissiveMap&&(this.emissiveMap.colorSpace=d.SRGBColorSpace),null!=this.alphaMap&&(this.alphaMap.colorSpace=d.LinearSRGBColorSpace),null!=this.lightMap&&(this.lightMap.colorSpace=d.LinearSRGBColorSpace),null!=this.lightSteps&&this.lightSteps.length>0){const t=new Uint8Array(this.lightSteps.length);for(let e=0;e<=t.length;e++)t[e]=255*this.lightSteps[e];e=new i(t,t.length,1,a),e.needsUpdate=!0}return new p(n({color:this.color.multiplyScalar(this.intensity),opacity:this.opacity,map:this.map,gradientMap:e,lightMap:this.lightMap,lightMapIntensity:this.lightMapIntensity,normalMap:this.normalMap,normalScale:this.normalScale,emissive:this.emissive,emissiveIntensity:this.emissiveIntensity,emissiveMap:this.emissiveMap,aoMap:this.aoMap,aoMapIntensity:this.aoMapIntensity,alphaMap:this.alphaMap,vertexColors:this.vertexColor}))}}e([l(),t("design:type",o)],ToonShader.prototype,"color",void 0),e([l({range:[0,1]}),t("design:type",Number)],ToonShader.prototype,"opacity",void 0),e([l({range:[0,10]}),t("design:type",Number)],ToonShader.prototype,"intensity",void 0),e([l(),t("design:type",r)],ToonShader.prototype,"map",void 0),e([l({type:Number,array:!0,range:[0,1]}),t("design:type",Array)],ToonShader.prototype,"lightSteps",void 0),e([l(),t("design:type",r)],ToonShader.prototype,"lightMap",void 0),e([l(),t("design:type",Number)],ToonShader.prototype,"lightMapIntensity",void 0),e([l(),t("design:type",r)],ToonShader.prototype,"normalMap",void 0),e([l(),t("design:type",s)],ToonShader.prototype,"normalScale",void 0),e([l(),t("design:type",r)],ToonShader.prototype,"aoMap",void 0),e([l(),t("design:type",Number)],ToonShader.prototype,"aoMapIntensity",void 0),e([l(),t("design:type",r)],ToonShader.prototype,"alphaMap",void 0),e([l(),t("design:type",o)],ToonShader.prototype,"emissive",void 0),e([l({range:[0,10]}),t("design:type",Number)],ToonShader.prototype,"emissiveIntensity",void 0),e([l(),t("design:type",r)],ToonShader.prototype,"emissiveMap",void 0),e([l(),t("design:type",Boolean)],ToonShader.prototype,"vertexColor",void 0);/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -43,6 +43,12 @@ export interface ParameterOptions {
|
|
|
43
43
|
* prefab: PrefabOf<BaseActor>
|
|
44
44
|
*/
|
|
45
45
|
prefabOf?: Type<BaseActor>;
|
|
46
|
+
/**
|
|
47
|
+
* When set, the parameter can bind to a VFX asset-level input instead of using a constant value.
|
|
48
|
+
* `spawn` means the bound value is sampled when particles are created.
|
|
49
|
+
* `live` means the bound value is sampled during runtime updates.
|
|
50
|
+
*/
|
|
51
|
+
vfxInputBindingMode?: 'spawn' | 'live';
|
|
46
52
|
}
|
|
47
53
|
export interface PropertyParameter {
|
|
48
54
|
name: string;
|
|
@@ -4,4 +4,5 @@ export declare const timeUniforms: {
|
|
|
4
4
|
elapsed: import("three-shader-graph").UniformFloatNode;
|
|
5
5
|
};
|
|
6
6
|
export declare function panCoord(speed: Vec2Node, tile: Vec2Node, coord: Vec2Node, time: FloatNode | number | null | undefined): Vec2Node;
|
|
7
|
+
export declare const time: import("three-shader-graph").UniformFloatNode;
|
|
7
8
|
//# sourceMappingURL=time.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{uniformFloat as e,varyingAttributes as o,vec2 as
|
|
1
|
+
import{uniformFloat as e,varyingAttributes as o,vec2 as t}from"three-shader-graph";export const elapsedTimeUniformName="hology_elapsed_time";export const timeUniforms={elapsed:e("hology_elapsed_time")};export function panCoord(e,r=t(1,1),m=o.uv,i){return m.multiply(r).add(e.multiplyScalar(i??timeUniforms.elapsed))}export const time=timeUniforms.elapsed;/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{expect as e,test as t}from"vitest";import{BoxGeometry as o,Euler as n,Group as s,Mesh as r,MeshBasicMaterial as a,Quaternion as i,Vector3 as l}from"three";import{importCollisionShapes as c}from"../scene/collision/collision-shape-import.js";import{BoxCollisionShape as m,CollisionShapeSource as d,toInstancedCollisionShape as p}from"../scene/collision/collision-shape.js";import{calculateOBB as u}from"../utils/obb-utils.js";function w(t,o,n=1e-5){e(t.distanceTo(o)).toBeLessThan(n)}function f(t,o,n=1e-5){e(t.angleTo(o)).toBeLessThan(n)}t("box import keeps a stable local-axis box and composes only the mesh transform",()=>{const t=new s,n=new o(4,1,2);n.rotateX(.2),n.rotateY(.65),n.translate(.4,-.15,.3);const p=new r(n,new a);p.position.set(3,-2,1),p.rotation.set(.35,1.1,-.45),p.scale.set(1.5,1,.75),t.add(p),t.updateMatrixWorld(!0);n.computeBoundingBox();const u=n.boundingBox,h=u.getCenter(new l),x=u.getSize(new l),[B]=c(t,{mesh:{collisions:{shapeType:"box"}}}),b=B,E=h.clone().multiply(p.scale).applyQuaternion(p.quaternion).add(p.position);e(b).toBeInstanceOf(m),e(b.source).toBe(d.rendered),w(b.dimensions,x),w(b.offset,E),f((new i).setFromEuler(b.rotation),p.quaternion),w(b.instancedOffset,h),f((new i).setFromEuler(b.instancedRotation),new i)}),t("obb import composes the mesh transform with the local OBB transform",()=>{const t=new s,n=new o(4,1,2);n.rotateX(.2),n.rotateY(.65),n.translate(.4,-.15,.3);const l=new r(n,new a);l.position.set(3,-2,1),l.rotation.set(.35,1.1,-.45),l.scale.set(1.5,1,.75),t.add(l),t.updateMatrixWorld(!0);const[p]=c(t,{mesh:{collisions:{shapeType:"obb"}}}),h=p,x=u(n),B=x.center.clone().multiply(l.scale).applyQuaternion(l.quaternion).add(l.position),b=l.quaternion.clone().multiply((new i).setFromEuler(x.rotation));e(h).toBeInstanceOf(m),e(h.source).toBe(d.rendered),w(h.offset,B),f((new i).setFromEuler(h.rotation),b),w(h.instancedOffset,x.center),f((new i).setFromEuler(h.instancedRotation),(new i).setFromEuler(x.rotation))}),t("convex import keeps a rotated child mesh transform exactly once",()=>{const e=new s,t=new s,n=new r(new o(1,2,3),new a);n.rotation.set(-Math.PI/2,0,0),t.add(n),e.add(t),e.updateMatrixWorld(!0);const[l]=c(e,{mesh:{collisions:{shapeType:"convex"}}});f((new i).setFromEuler(l.rotation),n.quaternion)}),t("instanced collision shapes use the mesh-local transform without mutating the cached shape",()=>{const t=new m(new l(1,2,3));t.source=d.rendered,t.offset.set(10,11,12),t.rotation.set(.4,.5,.6),t.instancedOffset=new l(1,2,3),t.instancedRotation=new n(.1,.2,.3);const o=p(t);e(o).not.toBe(t),w(o.offset,t.instancedOffset),f((new i).setFromEuler(o.rotation),(new i).setFromEuler(t.instancedRotation)),w(t.offset,new l(10,11,12)),f((new i).setFromEuler(t.rotation),(new i).setFromEuler(new n(.4,.5,.6)))});/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{expect as e,test as t}from"vitest";import{Vector3 as i}from"three";import{Vector3D as n}from"@hology/nebula";import{SerializedParamType as o}from"../scene/model.js";import{Curve2 as a}from"../utils/curve.js";import{VfxBehaviourLibrary as r,VfxInitializserLibrary as l}from"../effects/vfx/vfx-defs.js";import{createBoundBehaviour as u,createBoundInitializer as c}from"../effects/vfx/vfx-binding-runtime.js";import{VfxInputRuntime as p}from"../effects/vfx/vfx-input-runtime.js";function f(){return{age:0,life:1,acceleration:new n,velocity:new n,position:new n,transform:{}}}t("velocity initializer samples the latest bound vec3 input for newly spawned particles",()=>{const t=new p([{id:"launchVelocity",name:"launchVelocity",type:"vec3",defaultValue:[1,2,3]}]),n=c(l.velocity,{velocity:{type:o.Vector3,value:[0,0,0],binding:{type:"vfxInput",inputId:"launchVelocity"}}},{velocity:new i(0,0,0)},t),a={velocity:new i};n.initialize(a),e(a.velocity.toArray()).toEqual([1,2,3]),t.setInput("launchVelocity",new i(4,5,6));const r={velocity:new i};n.initialize(r),e(a.velocity.toArray()).toEqual([1,2,3]),e(r.velocity.toArray()).toEqual([4,5,6])}),t("lifetime initializer picks up changed bound values only for newly initialized particles",()=>{const t=new p([{id:"duration",name:"duration",type:"number",defaultValue:2}]),i=c(l.lifetime,{duration:{type:o.Number,value:1,binding:{type:"vfxInput",inputId:"duration"}}},{duration:1},t),n={};i.initialize(n),e(n.life).toBe(2),t.setInput("duration",5);const a={};i.initialize(a),e(n.life).toBe(2),e(a.life).toBe(5)}),t("force behaviour applies live-bound vec3 input changes to already active particles",()=>{const t=new p([{id:"forceInput",name:"forceInput",type:"vec3",defaultValue:[1,0,0]}]),l=u(r.force,{force:{type:o.Vector3,value:[0,0,0],binding:{type:"vfxInput",inputId:"forceInput"}}},{force:new i(0,0,0),ease:a.linear()},t),c=f();l.applyBehaviour(c,.016,0),e(c.acceleration.x).toBeGreaterThan(0),e(c.acceleration.y).toBe(0),t.setInput("forceInput",new i(0,2,0)),c.acceleration=new n,l.applyBehaviour(c,.016,0),e(c.acceleration.x).toBe(0),e(c.acceleration.y).toBeGreaterThan(0)}),t("live-bound behaviours keep constant params when only part of the definition is bound",()=>{const t=new p([{id:"targetInput",name:"targetInput",type:"vec3",defaultValue:[1,2,3]}]),n=u(r.attraction,{target:{type:o.Vector3,value:[0,0,0],binding:{type:"vfxInput",inputId:"targetInput"}},force:{type:o.Number,value:5},radius:{type:o.Number,value:7}},{target:new i(0,0,0),force:5,radius:7,easing:a.linear()},t);n.applyBehaviour(f(),.016,0);const l=n.inner;e(l.radius).toBe(7),e(l.force).toBe(500),e(l.targetPosition.x).toBe(1),e(l.targetPosition.y).toBe(2),e(l.targetPosition.z).toBe(3)});/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BufferGeometry, Euler, Vector3 } from "three";
|
|
2
|
+
export interface OBBData {
|
|
3
|
+
center: Vector3;
|
|
4
|
+
size: Vector3;
|
|
5
|
+
rotation: Euler;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Calculates an optimal Oriented Bounding Box (OBB) for a given geometry using Principal Component Analysis (PCA).
|
|
9
|
+
* This provides a tighter fit than an Axis-Aligned Bounding Box (AABB) for rotated shapes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function calculateOBB(geometry: BufferGeometry): OBBData;
|
|
12
|
+
//# sourceMappingURL=obb-utils.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{Euler as t,Matrix4 as e,Vector3 as n,Quaternion as o}from"three";export function calculateOBB(r){const a=r.attributes.position;if(!a||0===a.count)return{center:new n,size:new n,rotation:new t};const s=a.count,c=[],i=new n;for(let t=0;t<s;t++){const e=(new n).fromBufferAttribute(a,t);c.push(e),i.add(e)}i.divideScalar(s);let l=0,u=0,f=0,w=0,b=0,h=0;for(const t of c){const e=t.x-i.x,n=t.y-i.y,o=t.z-i.z;l+=e*e,u+=e*n,f+=e*o,w+=n*n,b+=n*o,h+=o*o}const p=function(t){let e=[[1,0,0],[0,1,0],[0,0,1]],n=[[t[0][0],t[0][1],t[0][2]],[t[1][0],t[1][1],t[1][2]],[t[2][0],t[2][1],t[2][2]]];for(let t=0;t<50;t++){let t=0,o=1,r=Math.abs(n[0][1]);if(Math.abs(n[0][2])>r&&(t=0,o=2,r=Math.abs(n[0][2])),Math.abs(n[1][2])>r&&(t=1,o=2,r=Math.abs(n[1][2])),r<1e-9)break;const a=.5*Math.atan2(2*n[t][o],n[o][o]-n[t][t]),s=Math.cos(a),c=Math.sin(a),i=n[t][t],l=n[o][o],u=n[t][o];n[t][t]=s*s*i-2*c*s*u+c*c*l,n[o][o]=c*c*i+2*c*s*u+s*s*l,n[t][o]=n[o][t]=0;for(let e=0;e<3;e++)if(e!==t&&e!==o){const r=n[e][t],a=n[e][o];n[e][t]=n[t][e]=s*r-c*a,n[e][o]=n[o][e]=c*r+s*a}for(let n=0;n<3;n++){const r=e[n][t],a=e[n][o];e[n][t]=s*r-c*a,e[n][o]=c*r+s*a}}return e}([[l/s,u/s,f/s],[u/s,w/s,b/s],[f/s,b/s,h/s]]),d=new e;d.set(p[0][0],p[1][0],p[2][0],0,p[0][1],p[1][1],p[2][1],0,p[0][2],p[1][2],p[2][2],0,0,0,0,1),d.determinant()<0&&d.set(-p[0][0],p[1][0],p[2][0],0,-p[0][1],p[1][1],p[2][1],0,-p[0][2],p[1][2],p[2][2],0,0,0,0,1);const m=(new t).setFromRotationMatrix(d),M=(new o).setFromEuler(m),y=M.clone().invert(),x=new n(1/0,1/0,1/0),z=new n(-1/0,-1/0,-1/0),B=new n;for(const t of c)B.copy(t).sub(i).applyQuaternion(y),x.min(B),z.max(B);const v=(new n).subVectors(z,x);return{center:(new n).addVectors(x,z).multiplyScalar(.5).clone().applyQuaternion(M).add(i),size:v,rotation:m}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hology/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.193",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
"recast-navigation": "0.39.0",
|
|
178
178
|
"rxjs": "7.8.1",
|
|
179
179
|
"three-mesh-bvh": "^0.7.5",
|
|
180
|
-
"three-shader-graph": "^0.2.
|
|
180
|
+
"three-shader-graph": "^0.2.45",
|
|
181
181
|
"three-stdlib": "2.34.0",
|
|
182
182
|
"ts-key-enum": "^2.0.12",
|
|
183
183
|
"typedi": "^0.10.0"
|