troika-three-utils
Advanced tools
Comparing version 0.50.0 to 0.50.3
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.50.3](https://github.com/protectwise/troika/compare/v0.50.2...v0.50.3) (2024-11-01) | ||
### Bug Fixes | ||
* Error in derived materials in Three r170 ([2402026](https://github.com/protectwise/troika/commit/240202662447040c0255f39e6c296207ba9a5457)) | ||
# [0.50.0](https://github.com/protectwise/troika/compare/v0.49.1...v0.50.0) (2024-10-11) | ||
@@ -8,0 +19,0 @@ |
@@ -118,3 +118,3 @@ import { ShaderChunk, UniformsUtils, MeshDepthMaterial, RGBADepthPacking, MeshDistanceMaterial, ShaderLib, Matrix4, Vector3, Mesh, CylinderGeometry, Vector2, MeshStandardMaterial, DoubleSide } from 'three'; | ||
* `fragmentMainOutro`. | ||
* @param {function({fragmentShader: string, vertexShader:string}): | ||
* @param {function({fragmentShader: string, vertexShader:string}): | ||
* {fragmentShader: string, vertexShader:string}} options.customRewriter - A function | ||
@@ -223,2 +223,7 @@ * for performing custom rewrites of the full shader code. Useful if you need to do something | ||
type: { | ||
get: () => baseMaterial.type, | ||
set: (value) => {baseMaterial.type = value;} | ||
}, | ||
isDerivedFrom: { | ||
@@ -225,0 +230,0 @@ writable: true, |
@@ -122,3 +122,3 @@ (function (global, factory) { | ||
* `fragmentMainOutro`. | ||
* @param {function({fragmentShader: string, vertexShader:string}): | ||
* @param {function({fragmentShader: string, vertexShader:string}): | ||
* {fragmentShader: string, vertexShader:string}} options.customRewriter - A function | ||
@@ -227,2 +227,7 @@ * for performing custom rewrites of the full shader code. Useful if you need to do something | ||
type: { | ||
get: () => baseMaterial.type, | ||
set: (value) => {baseMaterial.type = value;} | ||
}, | ||
isDerivedFrom: { | ||
@@ -229,0 +234,0 @@ writable: true, |
'use strict';(function(h,c){"object"===typeof exports&&"undefined"!==typeof module?c(exports,require("three")):"function"===typeof define&&define.amd?define(["exports","three"],c):(h="undefined"!==typeof globalThis?globalThis:h||self,c(h.troika_three_utils={},h.THREE))})(this,function(h,c){function q(b){return b.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,function(b,k){return(k=c.ShaderChunk[k])?q(k):b})}function m(b,a){let k=D(a),e=n.get(b);e||n.set(b,e=Object.create(null));if(e[k])return new e[k]; | ||
let g=`_onBeforeCompile${k}`,h=function(d,e){b.onBeforeCompile.call(this,d,e);e=this.customProgramCacheKey()+"|"+d.vertexShader+"|"+d.fragmentShader;var c=v[e];c||(c=E(this,d,a,k),c=v[e]=c);d.vertexShader=c.vertexShader;d.fragmentShader=c.fragmentShader;l(d.uniforms,this.uniforms);a.timeUniform&&(d.uniforms[a.timeUniform]={get value(){return Date.now()-F}});if(this[g])this[g](d)},t=function(){return w(a.chained?b:b.clone())},w=function(d){const c=Object.create(d,G);Object.defineProperty(c,"baseMaterial", | ||
{value:b});Object.defineProperty(c,"id",{value:H++});{var e=4294967295*Math.random()|0;let b=4294967295*Math.random()|0,a=4294967295*Math.random()|0,d=4294967295*Math.random()|0;e=(f[e&255]+f[e>>8&255]+f[e>>16&255]+f[e>>24&255]+"-"+f[b&255]+f[b>>8&255]+"-"+f[b>>16&15|64]+f[b>>24&255]+"-"+f[a&63|128]+f[a>>8&255]+"-"+f[a>>16&255]+f[a>>24&255]+f[d&255]+f[d>>8&255]+f[d>>16&255]+f[d>>24&255]).toUpperCase()}c.uuid=e;c.uniforms=l({},d.uniforms,a.uniforms);c.defines=l({},d.defines,a.defines);c.defines[`TROIKA_DERIVED_MATERIAL_${k}`]= | ||
"";c.extensions=l({},d.extensions,a.extensions);c._listeners=void 0;return c},G={constructor:{value:t},isDerivedMaterial:{value:!0},isDerivedFrom:{writable:!0,configurable:!0,value:function(b){const a=this.baseMaterial;return b===a||a.isDerivedMaterial&&a.isDerivedFrom(b)||!1}},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return b.customProgramCacheKey()+"|"+k}},onBeforeCompile:{get(){return h},set(b){this[g]=b}},copy:{writable:!0,configurable:!0,value:function(a){b.copy.call(this, | ||
a);b.isShaderMaterial||b.isDerivedMaterial||(l(this.extensions,a.extensions),l(this.defines,a.defines),l(this.uniforms,c.UniformsUtils.clone(a.uniforms)));return this}},clone:{writable:!0,configurable:!0,value:function(){const a=new b.constructor;return w(a).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let d=this._depthMaterial;d||(d=this._depthMaterial=m(b.isDerivedMaterial?b.getDepthMaterial():new c.MeshDepthMaterial({depthPacking:c.RGBADepthPacking}),a),d.defines.IS_DEPTH_MATERIAL= | ||
"",d.uniforms=this.uniforms);return d}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let d=this._distanceMaterial;d||(d=this._distanceMaterial=m(b.isDerivedMaterial?b.getDistanceMaterial():new c.MeshDistanceMaterial,a),d.defines.IS_DISTANCE_MATERIAL="",d.uniforms=this.uniforms);return d}},dispose:{writable:!0,configurable:!0,value(){const {_depthMaterial:a,_distanceMaterial:c}=this;a&&a.dispose();c&&c.dispose();b.dispose.call(this)}}};e[k]=t;return new t}function E(b,{vertexShader:a, | ||
fragmentShader:c},e,g){let {vertexDefs:k,vertexMainIntro:f,vertexMainOutro:h,vertexTransform:l,fragmentDefs:d,fragmentMainIntro:m,fragmentMainOutro:p,fragmentColorTransform:u,customRewriter:r,timeUniform:n}=e;k=k||"";f=f||"";h=h||"";d=d||"";m=m||"";p=p||"";if(l||r)a=q(a);if(u||r)c=c.replace(/^[ \t]*#include <((?:tonemapping|encodings|colorspace|fog|premultiplied_alpha|dithering)_fragment)>/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n"),c=q(c);r&&(c=r({vertexShader:a,fragmentShader:c}),a= | ||
c.vertexShader,c=c.fragmentShader);if(u){let b=[];c=c.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,a=>{b.push(a);return""});p=`${u}\n${b.join("\n")}\n${p}`}n&&(e=`\nuniform float ${n};\n`,k=e+k,d=e+d);l&&(k=`${k} | ||
"";c.extensions=l({},d.extensions,a.extensions);c._listeners=void 0;return c},G={constructor:{value:t},isDerivedMaterial:{value:!0},type:{get:()=>b.type,set:a=>{b.type=a}},isDerivedFrom:{writable:!0,configurable:!0,value:function(b){const a=this.baseMaterial;return b===a||a.isDerivedMaterial&&a.isDerivedFrom(b)||!1}},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return b.customProgramCacheKey()+"|"+k}},onBeforeCompile:{get(){return h},set(b){this[g]=b}},copy:{writable:!0,configurable:!0, | ||
value:function(a){b.copy.call(this,a);b.isShaderMaterial||b.isDerivedMaterial||(l(this.extensions,a.extensions),l(this.defines,a.defines),l(this.uniforms,c.UniformsUtils.clone(a.uniforms)));return this}},clone:{writable:!0,configurable:!0,value:function(){const a=new b.constructor;return w(a).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let d=this._depthMaterial;d||(d=this._depthMaterial=m(b.isDerivedMaterial?b.getDepthMaterial():new c.MeshDepthMaterial({depthPacking:c.RGBADepthPacking}), | ||
a),d.defines.IS_DEPTH_MATERIAL="",d.uniforms=this.uniforms);return d}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let d=this._distanceMaterial;d||(d=this._distanceMaterial=m(b.isDerivedMaterial?b.getDistanceMaterial():new c.MeshDistanceMaterial,a),d.defines.IS_DISTANCE_MATERIAL="",d.uniforms=this.uniforms);return d}},dispose:{writable:!0,configurable:!0,value(){const {_depthMaterial:a,_distanceMaterial:c}=this;a&&a.dispose();c&&c.dispose();b.dispose.call(this)}}};e[k]=t;return new t} | ||
function E(b,{vertexShader:a,fragmentShader:c},e,g){let {vertexDefs:k,vertexMainIntro:f,vertexMainOutro:h,vertexTransform:l,fragmentDefs:d,fragmentMainIntro:m,fragmentMainOutro:p,fragmentColorTransform:u,customRewriter:r,timeUniform:n}=e;k=k||"";f=f||"";h=h||"";d=d||"";m=m||"";p=p||"";if(l||r)a=q(a);if(u||r)c=c.replace(/^[ \t]*#include <((?:tonemapping|encodings|colorspace|fog|premultiplied_alpha|dithering)_fragment)>/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n"),c=q(c);r&&(c=r({vertexShader:a, | ||
fragmentShader:c}),a=c.vertexShader,c=c.fragmentShader);if(u){let b=[];c=c.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,a=>{b.push(a);return""});p=`${u}\n${b.join("\n")}\n${p}`}n&&(e=`\nuniform float ${n};\n`,k=e+k,d=e+d);l&&(k=`${k} | ||
void troikaVertexTransform${g}(inout vec3 position, inout vec3 normal, inout vec2 uv) { | ||
@@ -10,0 +10,0 @@ ${l} |
{ | ||
"name": "troika-three-utils", | ||
"version": "0.50.0", | ||
"version": "0.50.3", | ||
"description": "Various utilities related to Three.js", | ||
@@ -19,3 +19,3 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>", | ||
}, | ||
"gitHead": "57f2e7882ba85389f376bd62d7202355f7fe5d9e" | ||
"gitHead": "afcf40d9063b5dd0cb3c495f2f14ff0b1a9dc668" | ||
} |
@@ -69,3 +69,3 @@ import { voidMainRegExp } from './voidMainRegExp.js' | ||
* `fragmentMainOutro`. | ||
* @param {function({fragmentShader: string, vertexShader:string}): | ||
* @param {function({fragmentShader: string, vertexShader:string}): | ||
* {fragmentShader: string, vertexShader:string}} options.customRewriter - A function | ||
@@ -174,2 +174,7 @@ * for performing custom rewrites of the full shader code. Useful if you need to do something | ||
type: { | ||
get: () => baseMaterial.type, | ||
set: (value) => {baseMaterial.type = value} | ||
}, | ||
isDerivedFrom: { | ||
@@ -176,0 +181,0 @@ writable: true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116292
2080