@luma.gl/shadertools 9.0.20 → 9.0.21
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/dist.dev.js +12 -4
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +2 -3
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +4 -0
- package/dist/modules/lighting/lights/lighting-uniforms.d.ts +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms.js +4 -4
- package/dist/modules/lighting/phong-material/phong-material.d.ts +4 -4
- package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js +4 -0
- package/package.json +2 -2
- package/src/index.ts +2 -2
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +8 -5
- package/src/modules/lighting/lights/lighting-uniforms.ts +5 -5
- package/src/modules/lighting/phong-material/phong-material.ts +9 -6
package/dist/index.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export { picking } from "./modules/engine/picking/picking.js";
|
|
|
29
29
|
export type { LightingProps } from "./modules/lighting/lights/lighting-uniforms.js";
|
|
30
30
|
export { lighting } from "./modules/lighting/lights/lighting-uniforms.js";
|
|
31
31
|
export { dirlight } from "./modules/lighting/no-material/dirlight.js";
|
|
32
|
-
export type {
|
|
32
|
+
export type { GouraudMaterialProps } from "./modules/lighting/gouraud-material/gouraud-material.js";
|
|
33
33
|
export { gouraudMaterial } from "./modules/lighting/gouraud-material/gouraud-material.js";
|
|
34
|
-
export type {
|
|
34
|
+
export type { PhongMaterialProps } from "./modules/lighting/phong-material/phong-material.js";
|
|
35
35
|
export { phongMaterial } from "./modules/lighting/phong-material/phong-material.js";
|
|
36
36
|
export { pbrMaterial } from "./modules/lighting/pbr-material/pbr-material.js";
|
|
37
37
|
export type { BrightnessContrastProps } from "./modules/postprocessing/image-adjust-filters/brightnesscontrast.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,OAAO,EAAC,IAAI,EAAC,sCAAmC;AAEhD,YAAY,EAAC,YAAY,EAAC,+CAA4C;AAEtE,YAAY,EAAC,YAAY,EAAC,6CAA0C;AACpE,YAAY,EAAC,UAAU,EAAC,2CAAwC;AAChE,YAAY,EAAC,UAAU,EAAC,8CAA2C;AACnE,YAAY,EAAC,eAAe,EAAC,mDAAgD;AAC7E,OAAO,EAAC,oBAAoB,EAAC,sDAAmD;AAGhF,OAAO,EAAC,eAAe,EAAC,kCAA+B;AAEvD,OAAO,EAAC,qBAAqB,EAAC,uDAAoD;AAKlF,OAAO,EAAC,aAAa,EAAC,4CAAyC;AAC/D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACd,yCAAsC;AAGvC,YAAY,EAAC,uBAAuB,EAAC,kDAA+C;AACpF,OAAO,EAAC,uBAAuB,EAAC,kDAA+C;AAC/E,OAAO,EAAC,UAAU,EAAC,mDAAgD;AAGnE,OAAO,EAAC,sBAAsB,EAAC,kDAA+C;AAC9E,OAAO,EAAC,oBAAoB,IAAI,qBAAqB,EAAC,sDAAmD;AACzG,OAAO,EAAC,cAAc,EAAC,mDAAgD;AACvE,OAAO,EAAC,cAAc,IAAI,eAAe,EAAC,iDAA8C;AACxF,OAAO,EAAC,kBAAkB,IAAI,mBAAmB,EAAC,iDAA8C;AAGhG,OAAO,EAAC,uBAAuB,EAAC,6CAA0C;AAO1E,OAAO,EAAC,MAAM,EAAC,wCAAqC;AACpD,OAAO,EAAC,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export type GouraudMaterialProps =
|
|
3
|
-
export type GouraudMaterialUniforms = {
|
|
2
|
+
export type GouraudMaterialProps = {
|
|
4
3
|
ambient?: number;
|
|
5
4
|
diffuse?: number;
|
|
6
5
|
/** Specularity exponent */
|
|
@@ -8,5 +7,5 @@ export type GouraudMaterialUniforms = {
|
|
|
8
7
|
specularColor?: [number, number, number];
|
|
9
8
|
};
|
|
10
9
|
/** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
|
|
11
|
-
export declare const gouraudMaterial: ShaderModule<GouraudMaterialProps
|
|
10
|
+
export declare const gouraudMaterial: ShaderModule<GouraudMaterialProps>;
|
|
12
11
|
//# sourceMappingURL=gouraud-material.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gouraud-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;
|
|
1
|
+
{"version":3,"file":"gouraud-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAKtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,yIAAyI;AACzI,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,oBAAoB,CA4B9D,CAAC"}
|
|
@@ -26,6 +26,10 @@ export const gouraudMaterial = {
|
|
|
26
26
|
specularColor: [0.15, 0.15, 0.15]
|
|
27
27
|
},
|
|
28
28
|
getUniforms(props) {
|
|
29
|
+
const uniforms = { ...props };
|
|
30
|
+
if (uniforms.specularColor) {
|
|
31
|
+
uniforms.specularColor = uniforms.specularColor.map(x => x / 255);
|
|
32
|
+
}
|
|
29
33
|
return { ...gouraudMaterial.defaultUniforms, ...props };
|
|
30
34
|
}
|
|
31
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lighting-uniforms.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAEtE,OAAO,KAAK,EAAC,YAAY,EAAC,4CAAyC;AAenE,4BAA4B;AAE5B,MAAM,MAAM,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"lighting-uniforms.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAEtE,OAAO,KAAK,EAAC,YAAY,EAAC,4CAAyC;AAenE,4BAA4B;AAE5B,MAAM,MAAM,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CA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AAC,CAAC;IAC1C,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACpC,cAAc,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACvC,eAAe,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxC,iBAAiB,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC1C,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACpC,cAAc,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACvC,eAAe,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxC,iBAAiB,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;CAC3C,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,aAAa,EAAE,gBAAgB,EAAE,EAAE,CA8DtE,CAAC"}
|
|
@@ -55,15 +55,15 @@ export const lighting = {
|
|
|
55
55
|
lightPosition0: [1, 1, 2],
|
|
56
56
|
// TODO - could combine direction and attenuation
|
|
57
57
|
lightDirection0: [1, 1, 1],
|
|
58
|
-
lightAttenuation0: [1,
|
|
58
|
+
lightAttenuation0: [1, 0, 0],
|
|
59
59
|
lightColor1: [1, 1, 1],
|
|
60
60
|
lightPosition1: [1, 1, 2],
|
|
61
61
|
lightDirection1: [1, 1, 1],
|
|
62
|
-
lightAttenuation1: [1,
|
|
62
|
+
lightAttenuation1: [1, 0, 0],
|
|
63
63
|
lightColor2: [1, 1, 1],
|
|
64
64
|
lightPosition2: [1, 1, 2],
|
|
65
65
|
lightDirection2: [1, 1, 1],
|
|
66
|
-
lightAttenuation2: [1,
|
|
66
|
+
lightAttenuation2: [1, 0, 0]
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
function getUniforms(props, prevUniforms = {}) {
|
|
@@ -105,7 +105,7 @@ function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLig
|
|
|
105
105
|
const i = currentLight;
|
|
106
106
|
lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
|
|
107
107
|
lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
|
|
108
|
-
lightSourceUniforms[`lightAttenuation${i}`] =
|
|
108
|
+
lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
|
|
109
109
|
currentLight++;
|
|
110
110
|
}
|
|
111
111
|
for (const directionalLight of directionalLights) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
2
|
-
|
|
3
|
-
export type
|
|
2
|
+
import type { NumberArray3 } from "../../../lib/utils/uniform-types.js";
|
|
3
|
+
export type PhongMaterialProps = {
|
|
4
4
|
ambient?: number;
|
|
5
5
|
diffuse?: number;
|
|
6
6
|
/** Specularity exponent */
|
|
7
7
|
shininess?: number;
|
|
8
|
-
specularColor?:
|
|
8
|
+
specularColor?: NumberArray3;
|
|
9
9
|
};
|
|
10
10
|
/** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
|
|
11
|
-
export declare const phongMaterial: ShaderModule<PhongMaterialProps
|
|
11
|
+
export declare const phongMaterial: ShaderModule<PhongMaterialProps>;
|
|
12
12
|
//# sourceMappingURL=phong-material.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;
|
|
1
|
+
{"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAGtE,OAAO,KAAK,EAAC,YAAY,EAAC,4CAAyC;AAEnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,wIAAwI;AACxI,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CA4B1D,CAAC"}
|
|
@@ -26,6 +26,10 @@ export const phongMaterial = {
|
|
|
26
26
|
specularColor: [0.15, 0.15, 0.15]
|
|
27
27
|
},
|
|
28
28
|
getUniforms(props) {
|
|
29
|
+
const uniforms = { ...props };
|
|
30
|
+
if (uniforms.specularColor) {
|
|
31
|
+
uniforms.specularColor = uniforms.specularColor.map(x => x / 255);
|
|
32
|
+
}
|
|
29
33
|
return { ...phongMaterial.defaultUniforms, ...props };
|
|
30
34
|
}
|
|
31
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/shadertools",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.21",
|
|
4
4
|
"description": "Shader module system for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"@math.gl/types": "^4.0.0",
|
|
54
54
|
"wgsl_reflect": "^1.0.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "9d7d29778581c2408fc3f37723f6868983d0dab2"
|
|
57
57
|
}
|
package/src/index.ts
CHANGED
|
@@ -71,9 +71,9 @@ export {picking} from './modules/engine/picking/picking';
|
|
|
71
71
|
export type {LightingProps} from './modules/lighting/lights/lighting-uniforms';
|
|
72
72
|
export {lighting} from './modules/lighting/lights/lighting-uniforms';
|
|
73
73
|
export {dirlight} from './modules/lighting/no-material/dirlight';
|
|
74
|
-
export type {
|
|
74
|
+
export type {GouraudMaterialProps} from './modules/lighting/gouraud-material/gouraud-material';
|
|
75
75
|
export {gouraudMaterial} from './modules/lighting/gouraud-material/gouraud-material';
|
|
76
|
-
export type {
|
|
76
|
+
export type {PhongMaterialProps} from './modules/lighting/phong-material/phong-material';
|
|
77
77
|
export {phongMaterial} from './modules/lighting/phong-material/phong-material';
|
|
78
78
|
// export type {PBRMaterialSettings, PBRMaterialUniforms} from './modules/lighting/pbr-material/pbr';
|
|
79
79
|
export {pbrMaterial} from './modules/lighting/pbr-material/pbr-material';
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
import {ShaderModule} from '../../../lib/shader-module/shader-module';
|
|
6
6
|
import {lighting} from '../lights/lighting-uniforms';
|
|
7
7
|
import {PHONG_VS, PHONG_FS} from '../phong-material/phong-shaders-glsl';
|
|
8
|
+
import type {NumberArray3} from '../../../lib/utils/uniform-types';
|
|
8
9
|
|
|
9
|
-
export type GouraudMaterialProps =
|
|
10
|
-
|
|
11
|
-
export type GouraudMaterialUniforms = {
|
|
10
|
+
export type GouraudMaterialProps = {
|
|
12
11
|
ambient?: number;
|
|
13
12
|
diffuse?: number;
|
|
14
13
|
/** Specularity exponent */
|
|
@@ -17,7 +16,7 @@ export type GouraudMaterialUniforms = {
|
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
/** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
|
|
20
|
-
export const gouraudMaterial: ShaderModule<GouraudMaterialProps
|
|
19
|
+
export const gouraudMaterial: ShaderModule<GouraudMaterialProps> = {
|
|
21
20
|
name: 'gouraudMaterial',
|
|
22
21
|
// Note these are switched between phong and gouraud
|
|
23
22
|
vs: PHONG_FS.replace('phongMaterial', 'gouraudMaterial'),
|
|
@@ -38,7 +37,11 @@ export const gouraudMaterial: ShaderModule<GouraudMaterialProps, GouraudMaterial
|
|
|
38
37
|
shininess: 32,
|
|
39
38
|
specularColor: [0.15, 0.15, 0.15]
|
|
40
39
|
},
|
|
41
|
-
getUniforms(props: GouraudMaterialProps)
|
|
40
|
+
getUniforms(props: GouraudMaterialProps) {
|
|
41
|
+
const uniforms = {...props};
|
|
42
|
+
if (uniforms.specularColor) {
|
|
43
|
+
uniforms.specularColor = uniforms.specularColor.map(x => x / 255) as NumberArray3;
|
|
44
|
+
}
|
|
42
45
|
return {...gouraudMaterial.defaultUniforms, ...props};
|
|
43
46
|
}
|
|
44
47
|
};
|
|
@@ -34,7 +34,7 @@ export type PointLight = {
|
|
|
34
34
|
position: Readonly<NumberArray3>;
|
|
35
35
|
color?: Readonly<NumberArray3>;
|
|
36
36
|
intensity?: number;
|
|
37
|
-
attenuation?:
|
|
37
|
+
attenuation?: Readonly<NumberArray3>;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export type DirectionalLight = {
|
|
@@ -127,16 +127,16 @@ export const lighting: ShaderModule<LightingProps, LightingUniforms, {}> = {
|
|
|
127
127
|
lightPosition0: [1, 1, 2],
|
|
128
128
|
// TODO - could combine direction and attenuation
|
|
129
129
|
lightDirection0: [1, 1, 1],
|
|
130
|
-
lightAttenuation0: [1,
|
|
130
|
+
lightAttenuation0: [1, 0, 0],
|
|
131
131
|
|
|
132
132
|
lightColor1: [1, 1, 1],
|
|
133
133
|
lightPosition1: [1, 1, 2],
|
|
134
134
|
lightDirection1: [1, 1, 1],
|
|
135
|
-
lightAttenuation1: [1,
|
|
135
|
+
lightAttenuation1: [1, 0, 0],
|
|
136
136
|
lightColor2: [1, 1, 1],
|
|
137
137
|
lightPosition2: [1, 1, 2],
|
|
138
138
|
lightDirection2: [1, 1, 1],
|
|
139
|
-
lightAttenuation2: [1,
|
|
139
|
+
lightAttenuation2: [1, 0, 0]
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
|
|
@@ -198,7 +198,7 @@ function getLightSourceUniforms({
|
|
|
198
198
|
const i = currentLight as 0 | 1 | 2;
|
|
199
199
|
lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
|
|
200
200
|
lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
|
|
201
|
-
lightSourceUniforms[`lightAttenuation${i}`] =
|
|
201
|
+
lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
|
|
202
202
|
currentLight++;
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -5,19 +5,18 @@
|
|
|
5
5
|
import {ShaderModule} from '../../../lib/shader-module/shader-module';
|
|
6
6
|
import {lighting} from '../lights/lighting-uniforms';
|
|
7
7
|
import {PHONG_VS, PHONG_FS} from './phong-shaders-glsl';
|
|
8
|
+
import type {NumberArray3} from '../../../lib/utils/uniform-types';
|
|
8
9
|
|
|
9
|
-
export type PhongMaterialProps =
|
|
10
|
-
|
|
11
|
-
export type PhongMaterialUniforms = {
|
|
10
|
+
export type PhongMaterialProps = {
|
|
12
11
|
ambient?: number;
|
|
13
12
|
diffuse?: number;
|
|
14
13
|
/** Specularity exponent */
|
|
15
14
|
shininess?: number;
|
|
16
|
-
specularColor?:
|
|
15
|
+
specularColor?: NumberArray3;
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
/** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
|
|
20
|
-
export const phongMaterial: ShaderModule<PhongMaterialProps
|
|
19
|
+
export const phongMaterial: ShaderModule<PhongMaterialProps> = {
|
|
21
20
|
name: 'phongMaterial',
|
|
22
21
|
// Note these are switched between phong and gouraud
|
|
23
22
|
vs: PHONG_VS,
|
|
@@ -38,7 +37,11 @@ export const phongMaterial: ShaderModule<PhongMaterialProps, PhongMaterialUnifor
|
|
|
38
37
|
shininess: 32,
|
|
39
38
|
specularColor: [0.15, 0.15, 0.15]
|
|
40
39
|
},
|
|
41
|
-
getUniforms(props?: PhongMaterialProps)
|
|
40
|
+
getUniforms(props?: PhongMaterialProps) {
|
|
41
|
+
const uniforms = {...props};
|
|
42
|
+
if (uniforms.specularColor) {
|
|
43
|
+
uniforms.specularColor = uniforms.specularColor.map(x => x / 255) as NumberArray3;
|
|
44
|
+
}
|
|
42
45
|
return {...phongMaterial.defaultUniforms, ...props};
|
|
43
46
|
}
|
|
44
47
|
};
|