@luma.gl/shadertools
Advanced tools
Comparing version 9.0.20 to 9.0.21
@@ -32,5 +32,5 @@ /** | ||
export { dirlight } from "./modules/lighting/no-material/dirlight.js"; | ||
export type { PhongMaterialUniforms as GouraudMaterialUniforms } from "./modules/lighting/phong-material/phong-material.js"; | ||
export type { GouraudMaterialProps } from "./modules/lighting/gouraud-material/gouraud-material.js"; | ||
export { gouraudMaterial } from "./modules/lighting/gouraud-material/gouraud-material.js"; | ||
export type { PhongMaterialUniforms } from "./modules/lighting/phong-material/phong-material.js"; | ||
export type { PhongMaterialProps } from "./modules/lighting/phong-material/phong-material.js"; | ||
export { phongMaterial } from "./modules/lighting/phong-material/phong-material.js"; | ||
@@ -37,0 +37,0 @@ export { pbrMaterial } from "./modules/lighting/pbr-material/pbr-material.js"; |
import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
export type GouraudMaterialProps = GouraudMaterialUniforms; | ||
export type GouraudMaterialUniforms = { | ||
export type GouraudMaterialProps = { | ||
ambient?: number; | ||
@@ -11,3 +10,3 @@ diffuse?: number; | ||
/** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */ | ||
export declare const gouraudMaterial: ShaderModule<GouraudMaterialProps, GouraudMaterialUniforms>; | ||
export declare const gouraudMaterial: ShaderModule<GouraudMaterialProps>; | ||
//# sourceMappingURL=gouraud-material.d.ts.map |
@@ -29,4 +29,8 @@ // luma.gl | ||
getUniforms(props) { | ||
const uniforms = { ...props }; | ||
if (uniforms.specularColor) { | ||
uniforms.specularColor = uniforms.specularColor.map(x => x / 255); | ||
} | ||
return { ...gouraudMaterial.defaultUniforms, ...props }; | ||
} | ||
}; |
@@ -15,3 +15,3 @@ import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
intensity?: number; | ||
attenuation?: number; | ||
attenuation?: Readonly<NumberArray3>; | ||
}; | ||
@@ -18,0 +18,0 @@ export type DirectionalLight = { |
@@ -58,11 +58,11 @@ // luma.gl | ||
lightDirection0: [1, 1, 1], | ||
lightAttenuation0: [1, 1, 1], | ||
lightAttenuation0: [1, 0, 0], | ||
lightColor1: [1, 1, 1], | ||
lightPosition1: [1, 1, 2], | ||
lightDirection1: [1, 1, 1], | ||
lightAttenuation1: [1, 1, 1], | ||
lightAttenuation1: [1, 0, 0], | ||
lightColor2: [1, 1, 1], | ||
lightPosition2: [1, 1, 2], | ||
lightDirection2: [1, 1, 1], | ||
lightAttenuation2: [1, 1, 1] | ||
lightAttenuation2: [1, 0, 0] | ||
} | ||
@@ -109,3 +109,3 @@ }; | ||
lightSourceUniforms[`lightPosition${i}`] = pointLight.position; | ||
lightSourceUniforms[`lightAttenuation${i}`] = [pointLight.attenuation || 1, 0, 0]; | ||
lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0]; | ||
currentLight++; | ||
@@ -112,0 +112,0 @@ } |
import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
export type PhongMaterialProps = PhongMaterialUniforms; | ||
export type PhongMaterialUniforms = { | ||
import type { NumberArray3 } from "../../../lib/utils/uniform-types.js"; | ||
export type PhongMaterialProps = { | ||
ambient?: number; | ||
@@ -8,6 +8,6 @@ diffuse?: number; | ||
shininess?: number; | ||
specularColor?: [number, number, number]; | ||
specularColor?: NumberArray3; | ||
}; | ||
/** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */ | ||
export declare const phongMaterial: ShaderModule<PhongMaterialProps, PhongMaterialUniforms>; | ||
export declare const phongMaterial: ShaderModule<PhongMaterialProps>; | ||
//# sourceMappingURL=phong-material.d.ts.map |
@@ -29,4 +29,8 @@ // luma.gl | ||
getUniforms(props) { | ||
const uniforms = { ...props }; | ||
if (uniforms.specularColor) { | ||
uniforms.specularColor = uniforms.specularColor.map(x => x / 255); | ||
} | ||
return { ...phongMaterial.defaultUniforms, ...props }; | ||
} | ||
}; |
{ | ||
"name": "@luma.gl/shadertools", | ||
"version": "9.0.20", | ||
"version": "9.0.21", | ||
"description": "Shader module system for luma.gl", | ||
@@ -56,3 +56,3 @@ "type": "module", | ||
}, | ||
"gitHead": "fa850b5d4b398f7168529543a24662bf9df4c68e" | ||
"gitHead": "9d7d29778581c2408fc3f37723f6868983d0dab2" | ||
} |
@@ -74,5 +74,5 @@ // luma.gl | ||
export {dirlight} from './modules/lighting/no-material/dirlight'; | ||
export type {PhongMaterialUniforms as GouraudMaterialUniforms} from './modules/lighting/phong-material/phong-material'; | ||
export type {GouraudMaterialProps} from './modules/lighting/gouraud-material/gouraud-material'; | ||
export {gouraudMaterial} from './modules/lighting/gouraud-material/gouraud-material'; | ||
export type {PhongMaterialUniforms} from './modules/lighting/phong-material/phong-material'; | ||
export type {PhongMaterialProps} from './modules/lighting/phong-material/phong-material'; | ||
export {phongMaterial} from './modules/lighting/phong-material/phong-material'; | ||
@@ -79,0 +79,0 @@ // export type {PBRMaterialSettings, PBRMaterialUniforms} from './modules/lighting/pbr-material/pbr'; |
@@ -8,6 +8,5 @@ // luma.gl | ||
import {PHONG_VS, PHONG_FS} from '../phong-material/phong-shaders-glsl'; | ||
import type {NumberArray3} from '../../../lib/utils/uniform-types'; | ||
export type GouraudMaterialProps = GouraudMaterialUniforms; | ||
export type GouraudMaterialUniforms = { | ||
export type GouraudMaterialProps = { | ||
ambient?: number; | ||
@@ -21,3 +20,3 @@ diffuse?: number; | ||
/** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */ | ||
export const gouraudMaterial: ShaderModule<GouraudMaterialProps, GouraudMaterialUniforms> = { | ||
export const gouraudMaterial: ShaderModule<GouraudMaterialProps> = { | ||
name: 'gouraudMaterial', | ||
@@ -43,5 +42,9 @@ // Note these are switched between phong and gouraud | ||
}, | ||
getUniforms(props: GouraudMaterialProps): GouraudMaterialUniforms { | ||
getUniforms(props: GouraudMaterialProps) { | ||
const uniforms = {...props}; | ||
if (uniforms.specularColor) { | ||
uniforms.specularColor = uniforms.specularColor.map(x => x / 255) as NumberArray3; | ||
} | ||
return {...gouraudMaterial.defaultUniforms, ...props}; | ||
} | ||
}; |
@@ -37,3 +37,3 @@ // luma.gl | ||
intensity?: number; | ||
attenuation?: number; | ||
attenuation?: Readonly<NumberArray3>; | ||
}; | ||
@@ -131,3 +131,3 @@ | ||
lightDirection0: [1, 1, 1], | ||
lightAttenuation0: [1, 1, 1], | ||
lightAttenuation0: [1, 0, 0], | ||
@@ -137,7 +137,7 @@ lightColor1: [1, 1, 1], | ||
lightDirection1: [1, 1, 1], | ||
lightAttenuation1: [1, 1, 1], | ||
lightAttenuation1: [1, 0, 0], | ||
lightColor2: [1, 1, 1], | ||
lightPosition2: [1, 1, 2], | ||
lightDirection2: [1, 1, 1], | ||
lightAttenuation2: [1, 1, 1] | ||
lightAttenuation2: [1, 0, 0] | ||
} | ||
@@ -204,3 +204,3 @@ }; | ||
lightSourceUniforms[`lightPosition${i}`] = pointLight.position; | ||
lightSourceUniforms[`lightAttenuation${i}`] = [pointLight.attenuation || 1, 0, 0]; | ||
lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0]; | ||
currentLight++; | ||
@@ -207,0 +207,0 @@ } |
@@ -8,6 +8,5 @@ // luma.gl | ||
import {PHONG_VS, PHONG_FS} from './phong-shaders-glsl'; | ||
import type {NumberArray3} from '../../../lib/utils/uniform-types'; | ||
export type PhongMaterialProps = PhongMaterialUniforms; | ||
export type PhongMaterialUniforms = { | ||
export type PhongMaterialProps = { | ||
ambient?: number; | ||
@@ -17,7 +16,7 @@ diffuse?: number; | ||
shininess?: number; | ||
specularColor?: [number, number, number]; | ||
specularColor?: NumberArray3; | ||
}; | ||
/** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */ | ||
export const phongMaterial: ShaderModule<PhongMaterialProps, PhongMaterialUniforms> = { | ||
export const phongMaterial: ShaderModule<PhongMaterialProps> = { | ||
name: 'phongMaterial', | ||
@@ -43,5 +42,9 @@ // Note these are switched between phong and gouraud | ||
}, | ||
getUniforms(props?: PhongMaterialProps): PhongMaterialUniforms { | ||
getUniforms(props?: PhongMaterialProps) { | ||
const uniforms = {...props}; | ||
if (uniforms.specularColor) { | ||
uniforms.specularColor = uniforms.specularColor.map(x => x / 255) as NumberArray3; | ||
} | ||
return {...phongMaterial.defaultUniforms, ...props}; | ||
} | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1530697
33242