@woosh/meep-engine 2.42.4 → 2.42.5

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.
@@ -69,7 +69,7 @@ export class MaterialContext {
69
69
 
70
70
  const rewrite_material = this.adapter.rewriteMaterial.bind(this.adapter);
71
71
 
72
- if (material[MATERIAL_FLAG] === undefined) {
72
+ if (this.material[MATERIAL_FLAG] === undefined) {
73
73
  material.onBeforeCompile = composeCompile(this.material.onBeforeCompile, rewrite_material);
74
74
  material.needsUpdate = true;
75
75
 
@@ -6,6 +6,12 @@ import { fp_build_fragment_shader } from "../materials/fp_build_fragment_shader.
6
6
  import { fp_build_vertex_shader } from "../materials/fp_build_vertex_shader.js";
7
7
  import { fp_build_vertex_lighting_shared } from "../materials/fp_build_vertex_lighting_shared.js";
8
8
 
9
+ /**
10
+ * @readonly
11
+ * @type {string}
12
+ */
13
+ const PROPERTY_TRANSFORMER_MARKER = '@forward-plus-material-transformer';
14
+
9
15
  export class MaterialTransformer extends AbstractMaterialTransformer {
10
16
 
11
17
  /**
@@ -88,6 +94,17 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
88
94
  }
89
95
 
90
96
  transform(source) {
97
+ if (source.hasOwnProperty(PROPERTY_TRANSFORMER_MARKER)) {
98
+ // already transformed
99
+
100
+ if (source[PROPERTY_TRANSFORMER_MARKER] !== this) {
101
+ throw new Error('The material is already transformed, but is associated with a different transformer instance');
102
+ } else {
103
+ return source;
104
+ }
105
+
106
+ }
107
+
91
108
  let result = source;
92
109
 
93
110
  if (isLitMaterial(source)) {
@@ -96,12 +113,16 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
96
113
  // inherit uniforms directly
97
114
 
98
115
  if (source.isShaderMaterial) {
99
- result.uniforms = source.uniforms;
100
- result.defines = source.defines;
116
+ // TODO use Proxy
117
+ result.uniforms = Object.assign({}, source.uniforms);
118
+ result.defines = Object.assign({}, source.defines);
101
119
  }
102
120
 
103
121
  result.onBeforeCompile = composeCompile(source.onBeforeCompile, this.__on_before_compile);
104
122
 
123
+
124
+ result[PROPERTY_TRANSFORMER_MARKER] = this;
125
+
105
126
  }
106
127
 
107
128
  return result;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.42.4",
8
+ "version": "2.42.5",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",