@luma.gl/core
Advanced tools
Comparing version 9.0.0-alpha.40 to 9.0.0-alpha.41
@@ -1,2 +0,2 @@ | ||
import { arrayEqual } from "../utils/array-equal.js"; | ||
import { arrayEqual, arrayCopy } from "../utils/array-equal.js"; | ||
export class UniformBlock { | ||
@@ -43,3 +43,3 @@ constructor(props) { | ||
} | ||
this.uniforms[key] = value; | ||
this.uniforms[key] = arrayCopy(value); | ||
this.modifiedUniforms[key] = true; | ||
@@ -46,0 +46,0 @@ this.modified = true; |
/** Test if two arrays are deep equal, with a length limit that defaults to 16 */ | ||
export declare function arrayEqual(a: unknown, b: unknown, limit?: number): boolean; | ||
/** Copy a value */ | ||
export declare function arrayCopy<T>(a: T): T; | ||
//# sourceMappingURL=array-equal.d.ts.map |
@@ -21,2 +21,9 @@ import { isNumberArray } from "../utils/is-array.js"; | ||
} | ||
export function arrayCopy(a) { | ||
const numberArray = isNumberArray(a); | ||
if (numberArray) { | ||
return numberArray.slice(); | ||
} | ||
return a; | ||
} | ||
//# sourceMappingURL=array-equal.js.map |
{ | ||
"name": "@luma.gl/core", | ||
"version": "9.0.0-alpha.40", | ||
"version": "9.0.0-alpha.41", | ||
"description": "luma.gl API", | ||
@@ -45,3 +45,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "5a6f2bc7a4d24a65b74ae905844ad5bfc36c5645" | ||
"gitHead": "e8a5f47c6890d0b1883979c09114676b8fa90cc6" | ||
} |
// luma.gl, MIT license | ||
import type {ShaderUniformType} from '../../adapter/types/shader-types'; | ||
import type {UniformValue} from '../../adapter/types/types'; | ||
import {ShaderLayout, UniformBufferBindingLayout, UniformInfo} from '../../adapter/types/shader-layout'; | ||
import { arrayEqual } from '../utils/array-equal'; | ||
import { | ||
ShaderLayout, | ||
UniformInfo, | ||
UniformBufferBindingLayout | ||
} from '../../adapter/types/shader-layout'; | ||
import {arrayEqual, arrayCopy} from '../utils/array-equal'; | ||
/** | ||
/** | ||
* A uniform block holds values of the of uniform values for one uniform block / buffer. | ||
@@ -24,4 +28,4 @@ * It also does some book keeping on what has changed, to minimize unnecessary writes to uniform buffers. | ||
name?: string; | ||
shaderLayout?: ShaderLayout; | ||
uniformTypes?: Record<keyof TUniforms, Record<string, ShaderUniformType>> | ||
shaderLayout?: ShaderLayout; | ||
uniformTypes?: Record<keyof TUniforms, Record<string, ShaderUniformType>>; | ||
}) { | ||
@@ -32,4 +36,5 @@ this.name = props?.name; | ||
if (props?.name && props?.shaderLayout) { | ||
const binding = props?.shaderLayout.bindings | ||
?.find(binding => binding.type === 'uniform' && binding.name === props?.name); | ||
const binding = props?.shaderLayout.bindings?.find( | ||
binding => binding.type === 'uniform' && binding.name === props?.name | ||
); | ||
if (!binding) { | ||
@@ -73,3 +78,3 @@ throw new Error(props?.name); | ||
} | ||
this.uniforms[key] = value; | ||
this.uniforms[key] = arrayCopy(value); | ||
this.modifiedUniforms[key] = true; | ||
@@ -76,0 +81,0 @@ this.modified = true; |
@@ -25,1 +25,10 @@ // luma.gl, MIT license | ||
} | ||
/** Copy a value */ | ||
export function arrayCopy<T>(a: T): T { | ||
const numberArray = isNumberArray(a); | ||
if (numberArray) { | ||
return numberArray.slice() as T; | ||
} | ||
return a; | ||
} |
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
893538
13888