* Node: .getCacheKey() * cleanup
@@ -1,5 +1,5 @@
import { NodeUpdateType } from './constants.js';
-import { getNodesKeys } from './NodeUtils.js';
+import { getNodesKeys, getCacheKey } from './NodeUtils.js';
import { MathUtils } from 'three';
let _nodeId = 0;
@@ -58,6 +58,12 @@ class Node {
}
+ getCacheKey() {
+
+ return getCacheKey( this );
+ }
getHash( /*builder*/ ) {
return this.uuid;
@@ -1,5 +1,27 @@
import { Color, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from 'three';
+export const getCacheKey = ( object ) => {
+ let cacheKey = '{';
+ if ( object.isNode === true ) {
+ cacheKey += `uuid:"${ object.uuid }",`;
+ for ( const property of getNodesKeys( object ) ) {
+ cacheKey += `${ property }:${ object[ property ].getCacheKey() },`;
+ cacheKey += '}';
+ return cacheKey;
+};
export const getNodesKeys = ( object ) => {
const props = [];
import { Material, ShaderMaterial } from 'three';
-import { getNodesKeys } from '../core/NodeUtils.js';
+import { getNodesKeys, getCacheKey } from '../core/NodeUtils.js';
import ExpressionNode from '../core/ExpressionNode.js';
import {
float, vec3, vec4,
@@ -37,7 +37,7 @@ class NodeMaterial extends ShaderMaterial {
customProgramCacheKey() {
- return this.uuid + '-' + this.version;