@hology/core 0.0.152 → 0.0.153
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/vfx/rates.d.ts +4 -1
- package/dist/effects/vfx/rates.d.ts.map +1 -1
- package/dist/effects/vfx/rates.js +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +1 -0
- package/dist/effects/vfx/vfx-asset.d.ts.map +1 -1
- package/dist/effects/vfx/vfx-materializer.d.ts.map +1 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/rendering/fog/fog-volume-actor.d.ts.map +1 -1
- package/dist/rendering/fog/fog-volume-actor.js +1 -1
- package/dist/shader/builtin/decal-standard-shader.d.ts.map +1 -1
- package/dist/shader/builtin/decal-standard-shader.js +1 -1
- package/dist/shader/builtin/standard-shader.d.ts.map +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/parameter.d.ts +1 -0
- package/dist/shader/parameter.d.ts.map +1 -1
- package/dist/shader/sprite-shader.d.ts.map +1 -1
- package/dist/shader/sprite-shader.js +1 -1
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,8 +3,11 @@ import { Span, SpanValue } from '@hology/nebula';
|
|
|
3
3
|
export { Rate } from "@hology/nebula";
|
|
4
4
|
export declare class DelayRate extends Rate {
|
|
5
5
|
readonly delay: number;
|
|
6
|
-
|
|
6
|
+
duration?: number;
|
|
7
|
+
constructor(delay?: number, numPan?: number | SpanValue[] | Span, timePan?: number | SpanValue[] | Span, duration?: number);
|
|
8
|
+
private durationPlayed;
|
|
7
9
|
restart(): void;
|
|
10
|
+
getValue(time: number): number;
|
|
8
11
|
clone(): DelayRate;
|
|
9
12
|
}
|
|
10
13
|
export declare class OnceRate extends DelayRate {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rates.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/rates.ts"],"names":[],"mappings":"AAAA,OA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AA;CAkBd"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Rate as t}from"@hology/nebula";export{Rate}from"@hology/nebula";export class DelayRate extends t{constructor(t=0,e,s){super(e,
|
|
1
|
+
import{Rate as t}from"@hology/nebula";export{Rate}from"@hology/nebula";export class DelayRate extends t{constructor(t=0,e,i,s){super(e,i),this.delay=t,this.duration=s,this.durationPlayed=0,this.restart()}restart(){this.durationPlayed=0,this.nextTime=0,null!=this.delay&&this.delay>0?this.startTime=-this.delay:this.startTime=0}getValue(t){return null!=this.duration&&this.duration>0&&(this.durationPlayed+=t,this.durationPlayed>=this.duration)?0:super.getValue(t)}clone(){return new DelayRate(this.delay,this.numPan,this.timePan,this.duration)}}export class OnceRate extends DelayRate{constructor(t,e=1){super(t,e,1/0),this.count=e,this.calls=0,this.nextTime=0}clone(){return new OnceRate(this.delay,this.count)}init(){this.restart()}getValue(t){return this.calls++,this.startTime+=t,this.startTime>=this.nextTime?(this.nextTime=1/0,this.count):0}}export class ConstantRate extends DelayRate{constructor(t,e=1){super(t,e,1),this.perSecond=e,this.emitted=0,this.nextTime=0}clone(){return new ConstantRate(this.delay,this.perSecond)}init(){this.restart(),this.emitted=0}getValue(t){if(this.startTime+=t,this.startTime>=this.nextTime){let t=0;for(;this.emitted+t<this.startTime*this.perSecond;)t++;return this.emitted+=t,t}return 0}}/*
|
|
2
2
|
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vfx-asset.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/vfx-asset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAA0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1
|
-
import e,{Behaviour as t,Body as n,Emitter as i,Rate as a}from"@hology/nebula";import*as r from"three";import{Object3D as s}from"three";import{AttributeVec3Node as o,AttributeVec4Node as l,NodeShaderMaterial as c,RgbNode as u,UniformFloatNode as m,UniformVec3Node as p,Vec3ExpressionNode as d,Vec4Node as h,attributeFloat as f,attributeVec3 as y,attributeVec4 as w,attributes as g,clamp as v,float as b,glslFunction as x,lambertMaterial as M,log as A,pow as E,rgb as P,rgba as I,smoothstep as T,standardMaterial as C,textureSampler2d as S,transformed as B,uniformFloat as j,uniforms as k,varying as R,varyingAttributes as z,varyingVec3 as D,varyingVec4 as V}from"three-shader-graph";import{prepareClassParameters as L,prepareShapeParameters as O}from"../../scene/materializer.js";import{SerializedParamType as F}from"../../scene/model.js";import{ShapeLibrary as Q}from"../../scene/objects/shapes.js";import{fragmentLinearEyeDepth as W,linearEyeDepth as H}from"../../shader-nodes/depth.js";import{particleEnergyUniformName as U,particleTimeUniformName as q,particleUniforms as G,particleVelcoityUniformName as J}from"../../shader-nodes/particle.js";import{sampleFlipbook as N}from"../../shader-nodes/texture-sequence.js";import{DefaultInitializer as K}from"./initializsers.js";import{DelayRate as Y,OnceRate as X}from"./rates.js";import{StretchedSprite as _}from"./stretched-sprite.js";import{ThreeBlendingMode as Z}from"./vfx-asset.js";import{VfxBehaviourLibrary as $,VfxInitializserLibrary as ee}from"./vfx-defs.js";import{MultiRenderer as te}from"./vfx-renderers.js";import{WorldCollisionBehaviour as ne}from"./vfx-collision-behaviour.js";import{SpriteNodeShaderMaterial as ie}from"../../shader/sprite-shader.js";import{DecalUnlitShader as ae}from"../../shader/builtin/decal-unlit-shader.js";import{DecalStandardShader as re}from"../../shader/builtin/decal-standard-shader.js";export async function materializeVfx(t,n,i,a,o,l){let c=n;for(;null!=c.parent;)c=c.parent;const u=new s;u.name="particle system local",n.add(u);const m=new s;m.name="particle system world";const p=new te(m,u,r,a),d=new e;return(await Promise.all(t.vfx.emitters.slice().sort((e,t)=>(t.output.renderOrder??0)-(e.output.renderOrder??0)).map(async e=>{const t=await se(e,i,d,o,l);return t.setParentRecursive(d),t.emit()}))).forEach(e=>d.addEmitter(e)),d.addRenderer(p).emit({onEnd:()=>{}}),{container:m,system:d,dispose:()=>{m.removeFromParent(),u.removeFromParent(),p.dispose()}}}async function se(e,t,i,u,b){const E=function(e){let t;switch(e.rate.type){case"continuous":t=new Y(e.rate.delay??0,e.rate.count,e.rate.time);break;case"once":t=new X(e.rate.delay??0,e.rate.count);break;default:console.warn(`Failed to configure rate for emitter: ${JSON.stringify(e)}`),t=new a(0,1/0)}return t}(e);let P;switch(e.output.type){case"decal":P=new n(await async function(e,t){const n=!1!==e.unlit?new ae:new re;n.color=new r.Color(e.color),n instanceof ae?n.intensity=e.intensity??1:n.emissiveIntensity=e.intensity??1;if(e.colorMap){const i=await t.getTexture(e.colorMap);n.colorMap=i}if(e.alphaMap){const i=await t.getTexture(e.alphaMap);n.alphaMap=i}const i=n.build();i.blending=Z[e.blendingMode]??r.NormalBlending,i.transparent=!0,i.side=r.BackSide,i.depthTest=!1,null!=i&&!0===e.bloom&&(i.userData.hasBloom=!0);i.defines.IS_PARTICLE="";const a=new r.BoxGeometry(1,1,1),s=new r.Mesh(a,i);null!=e.renderOrder&&(s.renderOrder=e.renderOrder);return s}(e.output,t));break;case"sprite":P=new n(await async function(e,t,n){let i=null;i=null!=e.shader?await le(e,t,n):await async function(e,t){const n=null!=e.texture?await t.getTexture(e.texture):oe,i=S(n);let a=i.sample(z.uv);e.flipbook?.enabled&&(a=N(i,g.uv,e.flipbook.columns,e.flipbook.rows,G.time,e.flipbook.fps,e.flipbook.mode));const s=new m("rotation",0),o=new p("color").rgb,l=j("opacity",1),c=H.subtract(W).divide(H);let u=l;switch(e.opacityChannel??"red"){case"none":break;case"red":u=u.multiply(a.r);break;case"alpha":u=u.multiply(a.a)}if("number"==typeof e.softness&&e.softness>0){const t=v(c,0,1e3);u=u.multiply(T(0,.2*e.softness,t))}const d=x(h,{position:B.position,cameraPosition:k.cameraPosition,viewMatrix:k.viewMatrix,modelViewMatrix:k.modelViewMatrix,rotation:s},"\n // Scale from your model matrix\n vec2 scale;\n scale.x = length(vec3(modelMatrix[0].x, modelMatrix[0].y, modelMatrix[0].z));\n scale.y = length(vec3(modelMatrix[1].x, modelMatrix[1].y, modelMatrix[1].z));\n\n vec3 right, up;\n vec3 objectPos = (modelMatrix * vec4(0.0, 0.0, 0.0, 1.0)).xyz;\n\n #ifdef LOCK_Y_AXIS\n vec3 cameraPos = cameraPosition;\n vec3 lookDir = normalize(vec3(cameraPos.x - objectPos.x, 0.0, cameraPos.z - objectPos.z));\n right = normalize(vec3(lookDir.z, 0.0, -lookDir.x));\n up = vec3(0.0, 1.0, 0.0);\n #else\n right = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);\n up = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);\n #endif\n\n // then your shared code:\n vec2 center = vec2(0.5, 0.5);\n vec2 alignedPosition = (position.xy - (center - vec2(0.5))) * scale;\n\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n vec3 billboardPos = objectPos + right * rotatedPosition.x + up * rotatedPosition.y;\n\n return projectionMatrix * viewMatrix * vec4(billboardPos, 1.0);\n ");var f=new ie({color:I(o.multiply(a.rgb).multiplyScalar(e.intensity??1),u),transparent:!0,position:d,alphaTest:1e-4,uniforms:{color:{value:new r.Color(e.color)}}});f.alphaHash=!0,null!=f&&!0===e.bloom&&(f.userData.hasBloom=!0);return f.blending=Z[e.blendingMode]??r.NormalBlending,f}(e,t);i instanceof r.ShaderMaterial&&!0===e.lockY&&(i.defines.LOCK_Y_AXIS="");const a=new r.Mesh(new r.PlaneGeometry(1,1),i);return a.name="sprite",a}(e.output,t,b));break;case"stretchedSprite":P=new n(await async function(e,t){const n=null!=e.texture?await t.getTexture(e.texture):oe,i=S(n).sample(z.uv),a=V(new l("color")),s=a.rgb.multiply(i.rgb);let o=a.w;switch(e.opacityChannel??"red"){case"none":break;case"red":o=o.multiply(i.r);break;case"alpha":o=o.multiply(i.a)}if("number"==typeof e.softness&&e.softness>0){const t=H.subtract(W).divide(A(H)),n=v(t,0,1e3);o=o.multiply(T(0,.2*e.softness,n))}const c=x(h,{position:g.position,offset:y("offset"),modelViewMatrix:k.modelViewMatrix,velocity:w("velocity"),size:y("size"),rotation:f("rotation")},"\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n\n vec4 mvPosition = modelViewMatrix * vec4( offset , 1.0 );\n vec3 viewVelocity = normalMatrix * velocity.xyz;\n float vlength = length(viewVelocity); \n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, viewVelocity)) * avgSize; \n mvPosition.xyz -= (position.x + 0.5) * viewVelocity * (1.0 + lengthFactor / vlength) * avgSize;\n return projectionMatrix * mvPosition;\n ");var u=new ie({color:I(s.multiplyScalar(e.intensity??1),o),alphaTest:.1,transparent:!0,position:c,uniforms:{color:{value:new r.Color(e.color)}}});null!=u&&!0===e.bloom&&(u.userData.hasBloom=!0);u.blending=Z[e.blendingMode]??r.NormalBlending;const m=new _(new r.PlaneGeometry(1,1),u);return m.scaleFactor=e.scale,m}(e.output,t));break;case"shape":P=new n(await async function(e,t,n){if(null==e.shape)return console.log("Shape is null"),new s;const i=Q[e.shape];if(null==i)return console.error(`No shape with type ${e.shape}`),new s;const a=O(e.params??{}),l=i.geometry(a);let u=null;u=null!=e.shader?await le(e,t,n):null!=e.material?ce(await t.getMaterial(e.material)):function(){const e=R(new d("instanceColor")).rgb,t=R(new o("particleData")).x;return new c({color:M({color:e}).rgb.rgba(t),transparent:!0})}();null!=u&&!0===e.bloom&&(u.userData.hasBloom=!0);return new r.Mesh(l,u)}(e.output,t,b));break;case"mesh":P=new n(await async function(e,t,n){if(null==e.assetId)return console.warn("Can't use mesh as particle without asset id"),new s;const i=await t.getMesh(e.assetId),a=await t.getAsset(e.assetId);if(null!=e.shader||null!=e.material){let a;a=null!=e.shader?await le(e,t,n):ce(await t.getMaterial(e.material)),null!=a&&!0===e.bloom&&(a.userData.hasBloom=!0),null!=a&&!0===e.bloom&&(a.userData.hasBloom=!0),i.traverse(e=>{e instanceof r.Mesh&&(e.material=a)})}else{const e=[];if(null!=a.materialAssignments)for(const n of a.materialAssignments)i.traverse(i=>{i instanceof r.Mesh&&i.material instanceof r.Material&&i.material.color instanceof r.Color&&(i.material.name!=n.name&&null!=n.name||"#"+i.material.color.getHexString()!==n.color||e.push(t.getMaterial(n.materialId).then(e=>i.material=e)))});await Promise.all(e)}const o=[];if(i.traverse(e=>{e instanceof r.Mesh&&o.push(e)}),1===o.length){const e=o[0];return e.updateWorldMatrix(!0,!0),e.updateMatrixWorld(),e.matrix.copy(e.matrixWorld),e.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.removeFromParent(),e}return i}(e.output,t,b));break;case"trail":P=new n({type:"trail",taper:e.output.taper,headGeometry:null,dragTexture:!1,texture:null!=e.output.texture?await t.getTexture(e.output.texture):null,opacityChannel:e.output.opacityChannel,color:e.output.color,colorEnd:e.output.colorEnd,intensity:e.output.intensity??1,intensityEnd:e.output.intensityEnd??1,length:e.output.length,opacityStart:e.output.opacityStart,opacityEnd:e.output.opacityEnd,bloom:e.output.bloom,scrollSpeed:e.output.scrollSpeed,width:e.output.width,billboard:e.output.billboard??!1});break;default:console.error("Failed to create particly system body: "+JSON.stringify(e))}const C=new me;C.parent=i,C.setRate(E),C._space=e.output.space;const D=await Promise.all(e.initializers.filter(e=>!1!==e.enabled).filter(e=>null!=ee[e.type]).map(async e=>{const t=ee[e.type],n=await O(e.params??{});return t.build(n)}));D.push(P,new K),C.addInitializers(D);const L=await Promise.all(e.behaviours.filter(e=>!1!==e.enabled).filter(e=>null!=$[e.type]).map(async e=>{const t=$[e.type];for(const[n,i]of Object.entries(e.params))t.parameters&&null!=t.parameters[n]&&"curve"===t.parameters[n].type&&i.type!==F.Curve&&(i.type=F.Curve);const n=await O(e.params??{});return t.build(n)}).sort((e,t)=>e instanceof ne?1:0));L.push(new ue);for(const e of L)e instanceof ne&&(e.physics=u);C.addBehaviours(L);for(const n of e.children){const e=await se(n,t,i,u,b),a=new EmitterPool(()=>{const t=e.clone();return t.onExpired=()=>{const e=C.childEmitters.findIndex(e=>e.id===t.id);-1!=e&&C.childEmitters.splice(e,1),a.release(t)},t}),r=C.eventDispatcher,s=new Map;C.bindEmitterEvent=!0,r.addEventListener("PARTICLE_DEAD",e=>{const t=s.get(e.id);if(null!=t){const e=C.childEmitters.findIndex(e=>e.id===t.id);null!=e&&(t.stopEmit(),C.childEmitters.splice(e,1))}});let o="PARTICLE_CREATED";if("spawnEvent"in n)switch(n.spawnEvent){case"collision":o="PARTICLE_COLLISION";break;case"start":o="PARTICLE_CREATED"}r.addEventListener(o,e=>{const t=a.get();t.age=0,t.totalEmitTimes=-1,t.particles.length=0,t.currentEmitTime=0,t.cID=0,t.eventDispatcher.removeAllEventListeners(),C.childEmitters.push(t),s.set(e.id,t),t.parentParticle=e,t.system=C.system,t.emit()})}return C}const oe=(new r.TextureLoader).load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJkSURBVHjaxJeJbusgEEW94S1L//83X18M2MSuLd2pbqc4wZGqRLrKBsyZhQHny7Jk73xVL8xpVhWrcmiB5lX+6GJ5YgQ2owbAm8oIwH1VgKZUmGcRqKGGPgtEQQAzGR8hQ59fAmhJHSAagigJ4E7GPWRXOYC6owAd1JM6wDQPADyMWUqZRMqmAojHp1Vn6EQQEgUNMJLnUjMyJsM49wygBkAPw9dVFwXRkncCIIW3GRgoTQUZn6HxCMAFEFd8TwEQ78X4rHbILoAUmeT+RFG4UhQ6MiIAE4W/UsYFjuVjAIa2nIY4q1R0GFtQWG3E84lqw2GO2QOoCKBVu0BAPgDSU0eUDjjQenNkV/AW/pWChhpMTelo1a64AOKM30vk18GzTHXCNtI/Knz3DFBgsUqBGIjTInXRY1yA9xkVoqW5tVq3pDR9A0hfF5BSARmVnh7RMDCaIdcNgbPBkgzn1Bu+SfIEFSpSBmkxyrMicb0fAEuCZrWnN89veA/4XcakrPcjBWzkTuLjlbfTQPOlBhz+HwkqqPXmPQDdrQItxE1moGof1S74j/8txk8EHhTQrAE8qlwfqS5yukm1x/rAJ9Jiaa6nyATqD78aUVBhFo8b1V4DdTXdCW+IxA1zB4JhiOhZMEWO1HqnvdoHZ4FAMIhV9REF8FiUm0jsYPEJx/Fm/N8OhH90HI9YRHesWbXXZwAShU8qThe7H8YAuJmw5yOd989uRINKRTJAhoF8jbqrHKfeCYdIISZfSq26bk/K+yO3YvfKrVgiwQBHnwt8ynPB25+M8hceTt/ybPhnryJ78+tLgAEAuCFyiQgQB30AAAAASUVORK5CYII=");async function le(e,t,n){const i=n.get(e.shader);if(null==i)return console.error("No shader exists with name "+e.shader),new r.Material;const a=new i.type,s=await L(e.shaderParams,i.type,t,{getTexture:e=>t.getTexture(e.id),getMaterial:e=>t.getMaterial(e.id),getMesh:e=>t.getMesh(e.id)},void 0,void 0,void 0,void 0);return Object.assign(a,s),a.build()}function ce(e){const t=R(new d("instanceColor")).rgb;let n,i=R(new o("particleData")).x;if(e instanceof r.MeshStandardMaterial||e instanceof r.MeshLambertMaterial||e instanceof r.MeshBasicMaterial){let a=t.multiply(P(e.color));null!=e.map&&(a=a.multiply(S(e.map).sample(z.uv).rgb)),null!=e.alphaMap&&(i=i.multiply(S(e.alphaMap).sample(z.uv).r)),e instanceof r.MeshStandardMaterial?n=new c({color:C({color:a,emissive:P(e.emissive),emissiveIntensity:b(e.emissiveIntensity),roughness:e.roughness,metalness:e.metalness}).rgb.rgba(i),transparent:e.transparent,alphaTest:e.alphaTest}):e instanceof r.MeshLambertMaterial?n=new c({color:M({color:a}).rgb.rgba(i),transparent:e.transparent,alphaTest:e.alphaTest}):e instanceof r.MeshBasicMaterial&&(n=new c({color:a.rgb.rgba(i),transparent:e.transparent,alphaTest:e.alphaTest}))}else e instanceof c&&(n=e.clone(),n.defines.IS_PARTICLE="");return null!=n&&(!0===e.userData?.hasBloom&&null!=n&&(n.userData.hasBloom=!0),n.side=e.side,n.transparent=e.transparent),n??e}class ue extends t{initialize(e){e.body instanceof r.Object3D&&e.body.traverse(e=>{if(e instanceof r.Mesh){const t=e.material;t instanceof c&&(null!=t.uniforms[U]||null!=t.uniforms[q]||t.uniforms[J])}})}mutate(e,t,n){this.energize(e,t),e.target instanceof s&&e.target.traverse(t=>{if(t instanceof r.Mesh){const n=t.material;n instanceof c&&(null!=n.uniforms[U]&&(n.uniforms[U].value=this.energy),null!=n.uniforms[q]&&(n.uniforms[q].value=e.age),null!=n.uniforms[J]&&(n.uniforms[J].value=e.velocity))}})}}class me extends i{constructor(){super(...arguments),this.childEmitters=[],this.bindEmitterEvent=!1,this.onExpired=()=>{}}update(e){if(!this.isEmitting&&0===this.particles.length)return;this.age+=e,(this.dead||this.age>=this.life)&&this.destroy(),this.generate(e),this.integrate(e);let t=this.particles.length;for(;t--;){const e=this.particles[t];e.dead&&(this.system&&this.system.dispatch("PARTICLE_DEAD",e),this.bindEmitterEvent&&this.dispatch("PARTICLE_DEAD",e),this.system.pool.expire(e.reset()),this.particles.splice(t,1))}this.updateEmitterBehaviours(e),this.updateChildren(e),this.isEmitting||0!==this.particles.length||this.onExpired()}updateChildren(e){for(const t of this.childEmitters)null!=t.parentParticle?t.position.copy(t.parentParticle.position):t.setPosition(this.position),t.update(e)}clone(){const e=new me;return e.setRate(this.rate.clone()),e.behaviours=this.behaviours,e.initializers=this.initializers,e._space=this._space,e.body=this.body,e.parent=this.parent,e.system=this.system,e}setParentRecursive(e){this.system=e,this.childEmitters.forEach(t=>t.setParentRecursive(e))}}export class EmitterPool{constructor(e){this.creator=e,this.instances=[]}get(){0==this.instances.length&&this.instances.push(this.creator());return this.instances.pop()}release(e){this.instances.push(e)}dispose(){this.instances.length=0}}/*
|
|
1
|
+
import e,{Behaviour as t,Body as a,Emitter as n,Rate as s}from"@hology/nebula";import*as r from"three";import{Object3D as i}from"three";import{AttributeVec3Node as o,AttributeVec4Node as l,NodeShaderMaterial as c,RgbNode as u,UniformFloatNode as p,UniformVec3Node as m,Vec3ExpressionNode as h,Vec4Node as d,attributeFloat as f,attributeVec3 as y,attributeVec4 as w,attributes as g,clamp as b,float as v,glslFunction as A,lambertMaterial as E,log as M,pow as x,rgb as I,rgba as T,smoothstep as P,standardMaterial as B,textureSampler2d as C,uniformFloat as S,uniforms as R,varying as k,varyingAttributes as j,varyingVec3 as D,varyingVec4 as z}from"three-shader-graph";import{prepareClassParameters as V,prepareShapeParameters as F}from"../../scene/materializer.js";import{SerializedParamType as L}from"../../scene/model.js";import{ShapeLibrary as O}from"../../scene/objects/shapes.js";import{fragmentLinearEyeDepth as Q,linearEyeDepth as W}from"../../shader-nodes/depth.js";import{particleEnergyUniformName as H,particleTimeUniformName as U,particleUniforms as q,particleVelcoityUniformName as G}from"../../shader-nodes/particle.js";import{sampleFlipbook as J}from"../../shader-nodes/texture-sequence.js";import{DefaultInitializer as N}from"./initializsers.js";import{DelayRate as K,OnceRate as Y}from"./rates.js";import{StretchedSprite as X}from"./stretched-sprite.js";import{ThreeBlendingMode as Z}from"./vfx-asset.js";import{VfxBehaviourLibrary as _,VfxInitializserLibrary as $}from"./vfx-defs.js";import{MultiRenderer as ee}from"./vfx-renderers.js";import{WorldCollisionBehaviour as te}from"./vfx-collision-behaviour.js";import{getSpritePosition as ae,SpriteNodeShaderMaterial as ne}from"../../shader/sprite-shader.js";import{DecalUnlitShader as se}from"../../shader/builtin/decal-unlit-shader.js";import{DecalStandardShader as re}from"../../shader/builtin/decal-standard-shader.js";export async function materializeVfx(t,a,n,s,o,l){let c=a;for(;null!=c.parent;)c=c.parent;const u=new i;u.name="particle system local",a.add(u);const p=new i;p.name="particle system world";const m=new ee(p,u,r,s),h=new e;return(await Promise.all(t.vfx.emitters.slice().sort((e,t)=>(t.output.renderOrder??0)-(e.output.renderOrder??0)).map(async e=>{const t=await ie(e,n,h,o,l);return t.setParentRecursive(h),t.emit()}))).forEach(e=>h.addEmitter(e)),h.addRenderer(m).emit({onEnd:()=>{}}),{container:p,system:h,dispose:()=>{p.removeFromParent(),u.removeFromParent(),m.dispose()}}}async function ie(e,t,n,u,v){const x=function(e){let t;switch(e.rate.type){case"continuous":t=new K(e.rate.delay??0,e.rate.count,e.rate.time,e.rate.duration);break;case"once":t=new Y(e.rate.delay??0,e.rate.count);break;default:console.warn(`Failed to configure rate for emitter: ${JSON.stringify(e)}`),t=new s(0,1/0)}return t}(e);let I;switch(e.output.type){case"decal":I=new a(await async function(e,t){const a=!1!==e.unlit?new se:new re;a.color=new r.Color(e.color),a instanceof se?a.intensity=e.intensity??1:a.emissiveIntensity=e.intensity??1;if(e.colorMap){const n=await t.getTexture(e.colorMap);a.colorMap=n}if(e.alphaMap){const n=await t.getTexture(e.alphaMap);a.alphaMap=n}const n=a.build();n.blending=Z[e.blendingMode]??r.NormalBlending,n.transparent=!0,n.side=r.BackSide,n.depthTest=!1,null!=n&&!0===e.bloom&&(n.userData.hasBloom=!0);n.defines.IS_PARTICLE="";const s=new r.BoxGeometry(1,1,1),i=new r.Mesh(s,n);null!=e.renderOrder&&(i.renderOrder=e.renderOrder);return i}(e.output,t));break;case"sprite":I=new a(await async function(e,t,a){let n=null;n=null!=e.shader?await le(e,t,a):await async function(e,t){const a=null!=e.texture?await t.getTexture(e.texture):oe,n=C(a);let s=n.sample(j.uv);e.flipbook?.enabled&&(s=J(n,g.uv,e.flipbook.columns,e.flipbook.rows,q.time,e.flipbook.fps,e.flipbook.mode));const i=new p("rotation",0),o=new m("color").rgb,l=S("opacity",1),c=W.subtract(Q).divide(W);let u=l;switch(e.opacityChannel??"red"){case"none":break;case"red":u=u.multiply(s.r);break;case"alpha":u=u.multiply(s.a)}if("number"==typeof e.softness&&e.softness>0){const t=b(c,0,1e3);u=u.multiply(P(0,.2*e.softness,t))}const h=ae(i);var d=new ne({color:T(o.multiply(s.rgb).multiplyScalar(e.intensity??1),u),transparent:!0,position:h,alphaTest:1e-4,uniforms:{color:{value:new r.Color(e.color)}}});d.alphaHash=!0,null!=d&&!0===e.bloom&&(d.userData.hasBloom=!0);return d.blending=Z[e.blendingMode]??r.NormalBlending,d}(e,t);n instanceof r.ShaderMaterial&&!0===e.lockY&&(n.defines.LOCK_Y_AXIS="");const s=new r.Mesh(new r.PlaneGeometry(1,1),n);return s.name="sprite",s}(e.output,t,v));break;case"stretchedSprite":I=new a(await async function(e,t){const a=null!=e.texture?await t.getTexture(e.texture):oe,n=C(a).sample(j.uv),s=z(new l("color")),i=s.rgb.multiply(n.rgb);let o=s.w;switch(e.opacityChannel??"red"){case"none":break;case"red":o=o.multiply(n.r);break;case"alpha":o=o.multiply(n.a)}if("number"==typeof e.softness&&e.softness>0){const t=W.subtract(Q).divide(M(W)),a=b(t,0,1e3);o=o.multiply(P(0,.2*e.softness,a))}const c=A(d,{position:g.position,offset:y("offset"),modelViewMatrix:R.modelViewMatrix,velocity:w("velocity"),size:y("size"),rotation:f("rotation")},"\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n\n vec4 mvPosition = modelViewMatrix * vec4( offset , 1.0 );\n vec3 viewVelocity = normalMatrix * velocity.xyz;\n float vlength = length(viewVelocity); \n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, viewVelocity)) * avgSize; \n mvPosition.xyz -= (position.x + 0.5) * viewVelocity * (1.0 + lengthFactor / vlength) * avgSize;\n return projectionMatrix * mvPosition;\n ");var u=new ne({color:T(i.multiplyScalar(e.intensity??1),o),alphaTest:.1,transparent:!0,position:c,uniforms:{color:{value:new r.Color(e.color)}}});null!=u&&!0===e.bloom&&(u.userData.hasBloom=!0);u.blending=Z[e.blendingMode]??r.NormalBlending;const p=new X(new r.PlaneGeometry(1,1),u);return p.scaleFactor=e.scale,p}(e.output,t));break;case"shape":I=new a(await async function(e,t,a){if(null==e.shape)return console.log("Shape is null"),new i;const n=O[e.shape];if(null==n)return console.error(`No shape with type ${e.shape}`),new i;const s=F(e.params??{}),l=n.geometry(s);let u=null;u=null!=e.shader?await le(e,t,a):null!=e.material?ce(await t.getMaterial(e.material)):function(){const e=k(new h("instanceColor")).rgb,t=k(new o("particleData")).x;return new c({color:E({color:e}).rgb.rgba(t),transparent:!0})}();null!=u&&!0===e.bloom&&(u.userData.hasBloom=!0);return new r.Mesh(l,u)}(e.output,t,v));break;case"mesh":I=new a(await async function(e,t,a){if(null==e.assetId)return console.warn("Can't use mesh as particle without asset id"),new i;const n=await t.getMesh(e.assetId),s=await t.getAsset(e.assetId);if(null!=e.shader||null!=e.material){let s;s=null!=e.shader?await le(e,t,a):ce(await t.getMaterial(e.material)),null!=s&&!0===e.bloom&&(s.userData.hasBloom=!0),null!=s&&!0===e.bloom&&(s.userData.hasBloom=!0),n.traverse(e=>{e instanceof r.Mesh&&(e.material=s)})}else{const e=[];if(null!=s.materialAssignments)for(const a of s.materialAssignments)n.traverse(n=>{n instanceof r.Mesh&&n.material instanceof r.Material&&n.material.color instanceof r.Color&&(n.material.name!=a.name&&null!=a.name||"#"+n.material.color.getHexString()!==a.color||e.push(t.getMaterial(a.materialId).then(e=>n.material=e)))});await Promise.all(e)}const o=[];if(n.traverse(e=>{e instanceof r.Mesh&&o.push(e)}),1===o.length){const e=o[0];return e.updateWorldMatrix(!0,!0),e.updateMatrixWorld(),e.matrix.copy(e.matrixWorld),e.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.removeFromParent(),e}return n}(e.output,t,v));break;case"trail":I=new a({type:"trail",taper:e.output.taper,headGeometry:null,dragTexture:!1,texture:null!=e.output.texture?await t.getTexture(e.output.texture):null,opacityChannel:e.output.opacityChannel,color:e.output.color,colorEnd:e.output.colorEnd,intensity:e.output.intensity??1,intensityEnd:e.output.intensityEnd??1,length:e.output.length,opacityStart:e.output.opacityStart,opacityEnd:e.output.opacityEnd,bloom:e.output.bloom,scrollSpeed:e.output.scrollSpeed,width:e.output.width,billboard:e.output.billboard??!1});break;default:console.error("Failed to create particly system body: "+JSON.stringify(e))}const B=new pe;B.parent=n,B.setRate(x),B._space=e.output.space;const D=await Promise.all(e.initializers.filter(e=>!1!==e.enabled).filter(e=>null!=$[e.type]).map(async e=>{const t=$[e.type],a=await F(e.params??{});return t.build(a)}));D.push(I,new N),B.addInitializers(D);const V=await Promise.all(e.behaviours.filter(e=>!1!==e.enabled).filter(e=>null!=_[e.type]).map(async e=>{const t=_[e.type];for(const[a,n]of Object.entries(e.params))t.parameters&&null!=t.parameters[a]&&"curve"===t.parameters[a].type&&n.type!==L.Curve&&(n.type=L.Curve);const a=await F(e.params??{});return t.build(a)}).sort((e,t)=>e instanceof te?1:0));V.push(new ue);for(const e of V)e instanceof te&&(e.physics=u);B.addBehaviours(V);for(const a of e.children){const e=await ie(a,t,n,u,v),s=new EmitterPool(()=>{const t=e.clone();return t.onExpired=()=>{const e=B.childEmitters.findIndex(e=>e.id===t.id);-1!=e&&B.childEmitters.splice(e,1),s.release(t)},t}),r=B.eventDispatcher,i=new Map;B.bindEmitterEvent=!0,r.addEventListener("PARTICLE_DEAD",e=>{const t=i.get(e.id);if(null!=t){const e=B.childEmitters.findIndex(e=>e.id===t.id);null!=e&&(t.stopEmit(),B.childEmitters.splice(e,1))}});let o="PARTICLE_CREATED";if("spawnEvent"in a)switch(a.spawnEvent){case"collision":o="PARTICLE_COLLISION";break;case"start":o="PARTICLE_CREATED"}r.addEventListener(o,e=>{const t=s.get();t.age=0,t.totalEmitTimes=-1,t.particles.length=0,t.currentEmitTime=0,t.cID=0,t.eventDispatcher.removeAllEventListeners(),B.childEmitters.push(t),i.set(e.id,t),t.parentParticle=e,t.system=B.system,t.emit()})}return B}const oe=(new r.TextureLoader).load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJkSURBVHjaxJeJbusgEEW94S1L//83X18M2MSuLd2pbqc4wZGqRLrKBsyZhQHny7Jk73xVL8xpVhWrcmiB5lX+6GJ5YgQ2owbAm8oIwH1VgKZUmGcRqKGGPgtEQQAzGR8hQ59fAmhJHSAagigJ4E7GPWRXOYC6owAd1JM6wDQPADyMWUqZRMqmAojHp1Vn6EQQEgUNMJLnUjMyJsM49wygBkAPw9dVFwXRkncCIIW3GRgoTQUZn6HxCMAFEFd8TwEQ78X4rHbILoAUmeT+RFG4UhQ6MiIAE4W/UsYFjuVjAIa2nIY4q1R0GFtQWG3E84lqw2GO2QOoCKBVu0BAPgDSU0eUDjjQenNkV/AW/pWChhpMTelo1a64AOKM30vk18GzTHXCNtI/Knz3DFBgsUqBGIjTInXRY1yA9xkVoqW5tVq3pDR9A0hfF5BSARmVnh7RMDCaIdcNgbPBkgzn1Bu+SfIEFSpSBmkxyrMicb0fAEuCZrWnN89veA/4XcakrPcjBWzkTuLjlbfTQPOlBhz+HwkqqPXmPQDdrQItxE1moGof1S74j/8txk8EHhTQrAE8qlwfqS5yukm1x/rAJ9Jiaa6nyATqD78aUVBhFo8b1V4DdTXdCW+IxA1zB4JhiOhZMEWO1HqnvdoHZ4FAMIhV9REF8FiUm0jsYPEJx/Fm/N8OhH90HI9YRHesWbXXZwAShU8qThe7H8YAuJmw5yOd989uRINKRTJAhoF8jbqrHKfeCYdIISZfSq26bk/K+yO3YvfKrVgiwQBHnwt8ynPB25+M8hceTt/ybPhnryJ78+tLgAEAuCFyiQgQB30AAAAASUVORK5CYII=");async function le(e,t,a){const n=a.get(e.shader);if(null==n)return console.error("No shader exists with name "+e.shader),new r.Material;const s=new n.type,i=await V(e.shaderParams,n.type,t,{getTexture:e=>t.getTexture(e.id),getMaterial:e=>t.getMaterial(e.id),getMesh:e=>t.getMesh(e.id)},void 0,void 0,void 0,void 0);return Object.assign(s,i),s.build()}function ce(e){const t=k(new h("instanceColor")).rgb;let a,n=k(new o("particleData")).x;if(e instanceof r.MeshStandardMaterial||e instanceof r.MeshLambertMaterial||e instanceof r.MeshBasicMaterial){let s=t.multiply(I(e.color));null!=e.map&&(s=s.multiply(C(e.map).sample(j.uv).rgb)),null!=e.alphaMap&&(n=n.multiply(C(e.alphaMap).sample(j.uv).r)),e instanceof r.MeshStandardMaterial?a=new c({color:B({color:s,emissive:I(e.emissive),emissiveIntensity:v(e.emissiveIntensity),roughness:e.roughness,metalness:e.metalness}).rgb.rgba(n),transparent:e.transparent,alphaTest:e.alphaTest}):e instanceof r.MeshLambertMaterial?a=new c({color:E({color:s}).rgb.rgba(n),transparent:e.transparent,alphaTest:e.alphaTest}):e instanceof r.MeshBasicMaterial&&(a=new c({color:s.rgb.rgba(n),transparent:e.transparent,alphaTest:e.alphaTest}))}else e instanceof c&&(a=e.clone(),a.defines.IS_PARTICLE="");return null!=a&&(!0===e.userData?.hasBloom&&null!=a&&(a.userData.hasBloom=!0),a.side=e.side,a.transparent=e.transparent),a??e}class ue extends t{initialize(e){e.body instanceof r.Object3D&&e.body.traverse(e=>{if(e instanceof r.Mesh){const t=e.material;t instanceof c&&(null!=t.uniforms[H]||null!=t.uniforms[U]||t.uniforms[G])}})}mutate(e,t,a){this.energize(e,t),e.target instanceof i&&e.target.traverse(t=>{if(t instanceof r.Mesh){const a=t.material;a instanceof c&&(null!=a.uniforms[H]&&(a.uniforms[H].value=this.energy),null!=a.uniforms[U]&&(a.uniforms[U].value=e.age),null!=a.uniforms[G]&&(a.uniforms[G].value=e.velocity))}})}}class pe extends n{constructor(){super(...arguments),this.childEmitters=[],this.bindEmitterEvent=!1,this.onExpired=()=>{}}update(e){if(!this.isEmitting&&0===this.particles.length)return;this.age+=e,(this.dead||this.age>=this.life)&&this.destroy(),this.generate(e),this.integrate(e);let t=this.particles.length;for(;t--;){const e=this.particles[t];e.dead&&(this.system&&this.system.dispatch("PARTICLE_DEAD",e),this.bindEmitterEvent&&this.dispatch("PARTICLE_DEAD",e),this.system.pool.expire(e.reset()),this.particles.splice(t,1))}this.updateEmitterBehaviours(e),this.updateChildren(e),this.isEmitting||0!==this.particles.length||this.onExpired()}updateChildren(e){for(const t of this.childEmitters)null!=t.parentParticle?t.position.copy(t.parentParticle.position):t.setPosition(this.position),t.update(e)}clone(){const e=new pe;return e.setRate(this.rate.clone()),e.behaviours=this.behaviours,e.initializers=this.initializers,e._space=this._space,e.body=this.body,e.parent=this.parent,e.system=this.system,e}setParentRecursive(e){this.system=e,this.childEmitters.forEach(t=>t.setParentRecursive(e))}}export class EmitterPool{constructor(e){this.creator=e,this.instances=[]}get(){0==this.instances.length&&this.instances.push(this.creator());return this.instances.pop()}release(e){this.instances.push(e)}dispose(){this.instances.length=0}}/*
|
|
2
2
|
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fog-volume-actor.d.ts","sourceRoot":"","sources":["../../../src/rendering/fog/fog-volume-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,MAAM,OAAO,CAAC;AACxC,OAAO,EAAiB,SAAS,EAAa,MAAM,gBAAgB,CAAC;AAIrE,qBACa,SAAU,SAAQ,SAAS;IAGtC,WAAW,EAAE,MAAM,CAAM;IAGzB,aAAa,EAAE,MAAM,CAAI;IAGzB,YAAY,EAAE,MAAM,CAAI;IAGxB,aAAa,EAAE,MAAM,CAAI;
|
|
1
|
+
{"version":3,"file":"fog-volume-actor.d.ts","sourceRoot":"","sources":["../../../src/rendering/fog/fog-volume-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,MAAM,OAAO,CAAC;AACxC,OAAO,EAAiB,SAAS,EAAa,MAAM,gBAAgB,CAAC;AAIrE,qBACa,SAAU,SAAQ,SAAS;IAGtC,WAAW,EAAE,MAAM,CAAM;IAGzB,aAAa,EAAE,MAAM,CAAI;IAGzB,YAAY,EAAE,MAAM,CAAI;IAGxB,aAAa,EAAE,MAAM,CAAI;IASzB,sBAAsB,EAAE,MAAM,CAAI;IAGlC,MAAM,EAAE,KAAK,CAAoB;IAEjC,OAAO,CAAC,MAAM,CAEZ;IAEF,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CAI/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as
|
|
1
|
+
import{__decorate as e,__metadata as t}from"tslib";import{Color as i}from"three";import{Actor as o,attach as s,BaseActor as r,Parameter as n}from"../../gameplay";import{FogVolumeObject as a}from"./fog-volume-object";import{EditorSpriteComponent as p}from"../../gameplay/actors/builtin/components/editor-sprite-component";let h=class extends r{constructor(){super(...arguments),this.baseDensity=.5,this.heightFalloff=1,this.heightOffset=0,this.startDistance=3,this.scatteringDistribution=0,this.albedo=new i(1,1,.6),this.sprite=s(p,{file:"assets/cloud-icon.webp"})}onInit(){this.object.add(new a(this))}};e([n({range:[0,5],stepSize:.01,help:"The density (or thickness) of fog."}),t("design:type",Number)],h.prototype,"baseDensity",void 0),e([n(),t("design:type",Number)],h.prototype,"heightFalloff",void 0),e([n(),t("design:type",Number)],h.prototype,"heightOffset",void 0),e([n(),t("design:type",Number)],h.prototype,"startDistance",void 0),e([n({range:[-1,1],help:"\n Controls the direction in which light scatters inside the fog.\n\n - Positive values (> 0): More light is scattered forward, making beams and shafts more visible when looking toward the directional light source. (for dramatic god rays).\n - Zero: Even scattering in all directions—fog appears uniform.\n - Negative values (< 0): Fog is brighter when looking away from the directional light source.\n "}),t("design:type",Number)],h.prototype,"scatteringDistribution",void 0),e([n(),t("design:type",i)],h.prototype,"albedo",void 0),h=e([o()],h);export{h as FogVolume};/*
|
|
2
2
|
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decal-standard-shader.d.ts","sourceRoot":"","sources":["../../../src/shader/builtin/decal-standard-shader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,qBAAa,mBAAoB,SAAQ,eAAe;IACzC,KAAK,EAAE,KAAK,CAAwB;IACtB,OAAO,EAAE,MAAM,CAAI;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEL,SAAS,CAAC,EAAE,MAAM,CAAK;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;IAET,SAAS,CAAC,EAAE,MAAM,CAAK;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,WAAW,CAAC,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"decal-standard-shader.d.ts","sourceRoot":"","sources":["../../../src/shader/builtin/decal-standard-shader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,qBAAa,mBAAoB,SAAQ,eAAe;IACzC,KAAK,EAAE,KAAK,CAAwB;IACtB,OAAO,EAAE,MAAM,CAAI;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEL,SAAS,CAAC,EAAE,MAAM,CAAK;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;IAET,SAAS,CAAC,EAAE,MAAM,CAAK;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,WAAW,CAAC,EAAE,OAAO,CAAmB;IAIrD,MAAM;;;IA+DN,KAAK;CASN"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as e,__metadata as t}from"tslib";import{Color as a,Texture as s,Vector2 as r}from"three";import{colorToNormal as o,float as i,rgba as p,standardMaterial as l,textureSampler2d as n,uniforms as d,normalize as h,varying as m,rgb as c,AttributeVec3Node as y,ifDefApply as u,Vec3ExpressionNode as S}from"three-shader-graph";import{decalAlpha as g,decalNormal as v,decalUV as M}from"../../shader-nodes/decal.js";import{depthWorldPosition as D}from"../../shader-nodes/depth.js";import{DecalNodeShader as b}from"../decal-shader.js";import{Parameter as I}from"../parameter.js";export class DecalStandardShader extends b{constructor(){super(...arguments),this.color=new a("#FFFFFF"),this.opacity=1,this.roughness=1,this.metalness=0}output(){const e=M,t=m(new y("particleData"));let a=u("IS_PARTICLE",i(this.opacity),()=>t.x);null!=this.alphaMap&&(a=a.multiply(n(this.alphaMap).sample(e).r)),a=a.multiply(g);const s=m(u("IS_PARTICLE",c(this.color),()=>new S("instanceColor")));let r=u("IS_PARTICLE",c(this.color),()=>s.rgb),b=p(r,a);null!=this.colorMap&&(b=b.multiply(n(this.colorMap).sample(e)));let I=p(this.emissive,a);null!=this.emissiveMap&&(I=I.multiply(n(this.emissiveMap).sample(e)));let f=i(this.roughness);null!=this.roughnessMap&&(f=f.multiply(n(this.roughnessMap).sample(e).g));let F=i(this.metalness);null!=this.metalnessMap&&(F=F.multiply(n(this.metalnessMap).sample(e).b));let
|
|
1
|
+
import{__decorate as e,__metadata as t}from"tslib";import{Color as a,Texture as s,Vector2 as r}from"three";import{colorToNormal as o,float as i,rgba as p,standardMaterial as l,textureSampler2d as n,uniforms as d,normalize as h,varying as m,rgb as c,AttributeVec3Node as y,ifDefApply as u,Vec3ExpressionNode as S}from"three-shader-graph";import{decalAlpha as g,decalNormal as v,decalUV as M}from"../../shader-nodes/decal.js";import{depthWorldPosition as D}from"../../shader-nodes/depth.js";import{DecalNodeShader as b}from"../decal-shader.js";import{Parameter as I}from"../parameter.js";export class DecalStandardShader extends b{constructor(){super(...arguments),this.color=new a("#FFFFFF"),this.opacity=1,this.roughness=1,this.metalness=0,this.normalScale=new r(1,1)}output(){const e=M,t=m(new y("particleData"));let a=u("IS_PARTICLE",i(this.opacity),()=>t.x);null!=this.alphaMap&&(a=a.multiply(n(this.alphaMap).sample(e).r)),a=a.multiply(g);const s=m(u("IS_PARTICLE",c(this.color),()=>new S("instanceColor")));let r=u("IS_PARTICLE",c(this.color),()=>s.rgb),b=p(r,a);null!=this.colorMap&&(b=b.multiply(n(this.colorMap).sample(e)));let I=p(this.emissive,a);null!=this.emissiveMap&&(I=I.multiply(n(this.emissiveMap).sample(e)));let f=i(this.roughness);null!=this.roughnessMap&&(f=f.multiply(n(this.roughnessMap).sample(e).g));let F=i(this.metalness);null!=this.metalnessMap&&(F=F.multiply(n(this.metalnessMap).sample(e).b));let w=h(m(d.normalMatrix).multiplyVec(v));null!=this.normalMap&&(w=o(n(this.normalMap).sample(e),this.normalScale?.x??1,w,D,e));let x=null;return null!=this.aoMap&&(x=n(this.aoMap).sample(e).r),{color:l({color:b,emissive:I,emissiveIntensity:i(this.emissiveIntensity??1),roughness:f,metalness:F,normal:w,ambientOcclusion:x,ambientOcclusionIntensity:i(this.aoMapIntensity??1),worldPosition:D})}}build(){const e=super.build();return e.depthTest=!0,e.depthWrite=!1,e.userData.isDecal=!0,e}}e([I(),t("design:type",a)],DecalStandardShader.prototype,"color",void 0),e([I({range:[0,1]}),t("design:type",Number)],DecalStandardShader.prototype,"opacity",void 0),e([I(),t("design:type",s)],DecalStandardShader.prototype,"colorMap",void 0),e([I(),t("design:type",s)],DecalStandardShader.prototype,"alphaMap",void 0),e([I({range:[0,1]}),t("design:type",Number)],DecalStandardShader.prototype,"roughness",void 0),e([I(),t("design:type",s)],DecalStandardShader.prototype,"roughnessMap",void 0),e([I({range:[0,1]}),t("design:type",Number)],DecalStandardShader.prototype,"metalness",void 0),e([I(),t("design:type",s)],DecalStandardShader.prototype,"metalnessMap",void 0),e([I(),t("design:type",s)],DecalStandardShader.prototype,"aoMap",void 0),e([I(),t("design:type",Number)],DecalStandardShader.prototype,"aoMapIntensity",void 0),e([I(),t("design:type",a)],DecalStandardShader.prototype,"emissive",void 0),e([I({range:[0,10]}),t("design:type",Number)],DecalStandardShader.prototype,"emissiveIntensity",void 0),e([I(),t("design:type",s)],DecalStandardShader.prototype,"emissiveMap",void 0),e([I(),t("design:type",s)],DecalStandardShader.prototype,"normalMap",void 0),e([I(),t("design:type",r)],DecalStandardShader.prototype,"normalScale",void 0);/*
|
|
2
2
|
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-shader.d.ts","sourceRoot":"","sources":["../../../src/shader/builtin/standard-shader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,8BAA8B,EAAkB,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChI,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAOtC,qBAAa,cAAe,SAAQ,MAAM;IAE3B,KAAK,EAAE,KAAK,CAAwB;IAChB,GAAG,CAAC,EAAE,OAAO,CAA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}
|
|
@@ -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 s}from"../shader.js";import{Parameter as o}from"../parameter.js";import{removeObjectUndefined as p}from"../../utils/collections.js";const l=new r;export class StandardShader extends s{constructor(){super(...arguments),this.color=new t("#FFFFFF"),this.opacity=1,this.roughness=1,this.metalness=0,this.heightMap=l}build(){const e=null!=this.normalMap&&null!=this.map&&null!=this.heightMap&&this.heightMap!=l&&0!==this.heightScale;return new(e?ParallaxStandardMaterial:n)(p({color:this.color,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([o(),a("design:type",t)],StandardShader.prototype,"color",void 0),e([o({label:"Color Map"}),a("design:type",r)],StandardShader.prototype,"map",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"opacity",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"alphaMap",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"roughness",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"roughnessMap",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"metalness",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"metalnessMap",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"lightMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"lightMapIntensity",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"aoMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"aoMapIntensity",void 0),e([o(),a("design:type",t)],StandardShader.prototype,"emissive",void 0),e([o({range:[0,10]}),a("design:type",Number)],StandardShader.prototype,"emissiveIntensity",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"emissiveMap",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"bumpMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"bumpScale",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"normalMap",void 0),e([o(),a("design:type",i)],StandardShader.prototype,"normalScale",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"displacementMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"displacementScale",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"displacementBias",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"envMap",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"envMapIntensity",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"refractionRatio",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"heightMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"heightScale",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 varying vec3 vViewDirTS;\n varying mat3 vTBN;\n "),e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","\n #include <begin_vertex>\n vec3 N = normalize(normalMatrix * normal);\n vec3 T = normalize(normalMatrix * tangent.xyz);\n vec3 B = cross(N, T) * tangent.w;\n vTBN = mat3(T, B, N);\n\n vec3 viewDir = cameraPosition - (modelMatrix * vec4(transformed, 1.0)).xyz;\n vViewDirTS = normalize(vTBN * viewDir);\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 varying vec3 vViewDirTS;\n varying mat3 vTBN;\n\n vec2 parallaxOffset(vec2 uv, vec3 viewDirTS) {\n float h = texture(heightMap, uv).r;\n return uv - (viewDirTS.xy / viewDirTS.z) * (h * heightScale);\n }\n\n vec2 parallaxOcclusion2(vec2 uv, vec3 viewDirTS) {\n vec3 viewDir = normalize(vViewPosition);\n vec3 vv = -viewDir * vTBN;\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 // Probably should use actual normal but it might not matter\n vec3 nNormal = vec3(0.0, 0.0, 1.0);\n float nNumSamples = mix(float(maxLayers), float(minLayers), dot(viewDir, nNormal));\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 < 50; 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 vec2 uvPOM = vMapUv ;\n if (parallaxType == 1) {\n uvPOM = parallaxOffset(vMapUv , vViewDirTS);\n } else if (parallaxType == 2) {\n uvPOM = parallaxOcclusion2(vMapUv , vViewDirTS);\n }\n\n\n vec4 texelColor = texture2D(map, uvPOM);\n //texelColor = mapTexelToLinear(texelColor);\n diffuseColor *= texelColor;\n "),e.fragmentShader=e.fragmentShader.replace("#include <normal_fragment_maps>","\n vec3 mapN = texture2D(normalMap, uvPOM).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\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 s}from"../shader.js";import{Parameter as o}from"../parameter.js";import{removeObjectUndefined as p}from"../../utils/collections.js";const l=new r;export class StandardShader extends s{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=l}build(){const e=null!=this.normalMap&&null!=this.map&&null!=this.heightMap&&this.heightMap!=l&&0!==this.heightScale;return new(e?ParallaxStandardMaterial:n)(p({color:this.color,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([o(),a("design:type",t)],StandardShader.prototype,"color",void 0),e([o({label:"Color Map"}),a("design:type",r)],StandardShader.prototype,"map",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"opacity",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"alphaMap",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"roughness",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"roughnessMap",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"metalness",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"metalnessMap",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"lightMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"lightMapIntensity",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"aoMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"aoMapIntensity",void 0),e([o(),a("design:type",t)],StandardShader.prototype,"emissive",void 0),e([o({range:[0,10]}),a("design:type",Number)],StandardShader.prototype,"emissiveIntensity",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"emissiveMap",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"bumpMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"bumpScale",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"normalMap",void 0),e([o(),a("design:type",i)],StandardShader.prototype,"normalScale",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"displacementMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"displacementScale",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"displacementBias",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"envMap",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"envMapIntensity",void 0),e([o({range:[0,1]}),a("design:type",Number)],StandardShader.prototype,"refractionRatio",void 0),e([o(),a("design:type",r)],StandardShader.prototype,"heightMap",void 0),e([o(),a("design:type",Number)],StandardShader.prototype,"heightScale",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 varying vec3 vViewDirTS;\n varying mat3 vTBN;\n "),e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","\n #include <begin_vertex>\n vec3 N = normalize(normalMatrix * normal);\n vec3 T = normalize(normalMatrix * tangent.xyz);\n vec3 B = cross(N, T) * tangent.w;\n vTBN = mat3(T, B, N);\n\n vec3 viewDir = cameraPosition - (modelMatrix * vec4(transformed, 1.0)).xyz;\n vViewDirTS = normalize(vTBN * viewDir);\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 varying vec3 vViewDirTS;\n varying mat3 vTBN;\n\n vec2 parallaxOffset(vec2 uv, vec3 viewDirTS) {\n float h = texture(heightMap, uv).r;\n return uv - (viewDirTS.xy / viewDirTS.z) * (h * heightScale);\n }\n\n vec2 parallaxOcclusion2(vec2 uv, vec3 viewDirTS) {\n vec3 viewDir = normalize(vViewPosition);\n vec3 vv = -viewDir * vTBN;\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 // Probably should use actual normal but it might not matter\n vec3 nNormal = vec3(0.0, 0.0, 1.0);\n float nNumSamples = mix(float(maxLayers), float(minLayers), dot(viewDir, nNormal));\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 < 50; 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 vec2 uvPOM = vMapUv ;\n if (parallaxType == 1) {\n uvPOM = parallaxOffset(vMapUv , vViewDirTS);\n } else if (parallaxType == 2) {\n uvPOM = parallaxOcclusion2(vMapUv , vViewDirTS);\n }\n\n\n vec4 texelColor = texture2D(map, uvPOM);\n //texelColor = mapTexelToLinear(texelColor);\n diffuseColor *= texelColor;\n "),e.fragmentShader=e.fragmentShader.replace("#include <normal_fragment_maps>","\n vec3 mapN = texture2D(normalMap, uvPOM).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\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 (©) 2025 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter.d.ts","sourceRoot":"","sources":["../../src/shader/parameter.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO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,OAAO,CAAC,EAAE,CAAA;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAKD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,gBAAgB,CAAA;CAC1B;AAsBD,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,IACjC,QAAQ,MAAM,EAAE,cAAc,MAAM,GAAG,MAAM,EAAE,QAAQ,OAAO,KAAG,IAAI,CAevF;AA+CD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,QAK7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite-shader.d.ts","sourceRoot":"","sources":["../../src/shader/sprite-shader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAyD,SAAS,EAAO,MAAM,oBAAoB,CAAC;AACpH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,8BAAsB,gBAAgB;IACpC,KAAK,IAAI,QAAQ;IAwBjB,QAAQ,CAAC,MAAM,IAAI,gBAAgB;CACpC;AAGD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"sprite-shader.d.ts","sourceRoot":"","sources":["../../src/shader/sprite-shader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAyD,SAAS,EAAO,MAAM,oBAAoB,CAAC;AACpH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,8BAAsB,gBAAgB;IACpC,KAAK,IAAI,QAAQ;IAwBjB,QAAQ,CAAC,MAAM,IAAI,gBAAgB;CACpC;AAGD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,YAgCpD;AAED,qBAAa,wBAAyB,SAAQ,kBAAkB;IAE9D,IAAI,KAAK,IAGQ,KAAK,CAAC,mBAAmB,CADzC;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,mBAAmB,EAEzC;IACD,IAAI,QAAQ,IAGQ,MAAM,CADzB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAEzB;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{NodeShaderMaterial as o}from"../shader-nodes/index.js";import{Vec4Node as
|
|
1
|
+
import{NodeShaderMaterial as o}from"../shader-nodes/index.js";import{Vec4Node as e,glslFunction as i,transformed as t,uniforms as r,UniformFloatNode as n}from"three-shader-graph";import*as a from"three";export class SpriteNodeShader{build(){const o=this.output(),e=getSpritePosition(new n("rotation",0));return new SpriteNodeShaderMaterial({color:o.color,discard:o.discard,transparent:o.transparent??!0,position:e,uniforms:{color:{value:new a.Color(0)}}})}}export function getSpritePosition(o){return i(e,{position:t.position,cameraPosition:r.cameraPosition,viewMatrix:r.viewMatrix,modelViewMatrix:r.modelViewMatrix,rotation:o},"\n // Scale from your model matrix\n vec2 scale;\n scale.x = length(vec3(modelMatrix[0].x, modelMatrix[0].y, modelMatrix[0].z));\n scale.y = length(vec3(modelMatrix[1].x, modelMatrix[1].y, modelMatrix[1].z));\n\n vec3 right, up;\n vec3 objectPos = (modelMatrix * vec4(0.0, 0.0, 0.0, 1.0)).xyz;\n\n #ifdef LOCK_Y_AXIS\n vec3 cameraPos = cameraPosition;\n vec3 lookDir = normalize(vec3(cameraPos.x - objectPos.x, 0.0, cameraPos.z - objectPos.z));\n right = normalize(vec3(lookDir.z, 0.0, -lookDir.x));\n up = vec3(0.0, 1.0, 0.0);\n #else\n right = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);\n up = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);\n #endif\n\n // then your shared code:\n vec2 center = vec2(0.5, 0.5);\n vec2 alignedPosition = (position.xy - (center - vec2(0.5))) * scale;\n\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n vec3 billboardPos = objectPos + right * rotatedPosition.x + up * rotatedPosition.y;\n\n return projectionMatrix * viewMatrix * vec4(billboardPos, 1.0);\n ")}export class SpriteNodeShaderMaterial extends o{get color(){return this.uniforms.color.value}set color(o){this.uniforms.color.value=new a.Color(o)}get rotation(){return this.uniforms.rotation.value}set rotation(o){this.uniforms.rotation.value=o}}/*
|
|
2
2
|
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hology/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.153",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
"dependencies": {
|
|
169
169
|
"@babel/runtime": "^7.24.8",
|
|
170
170
|
"@dimforge/rapier3d-compat": "^0.14.0",
|
|
171
|
-
"@hology/nebula": "^0.0.
|
|
171
|
+
"@hology/nebula": "^0.0.153",
|
|
172
172
|
"@plumier/reflect": "^1.1.0",
|
|
173
173
|
"@recast-navigation/three": "0.39.0",
|
|
174
174
|
"recast-navigation": "0.39.0",
|