three 基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
865 B

2 years ago
import { TempNode } from '../core/TempNode.js';
class LightNode extends TempNode {
constructor( scope ) {
super( 'v3', { shared: false } );
this.scope = scope || LightNode.TOTAL;
}
generate( builder, output ) {
if ( builder.isCache( 'light' ) ) {
return builder.format( 'reflectedLight.directDiffuse', this.type, output );
} else {
console.warn( 'THREE.LightNode is only compatible in "light" channel.' );
return builder.format( 'vec3( 0.0 )', this.type, output );
}
}
copy( source ) {
super.copy( source );
this.scope = source.scope;
return this;
}
toJSON( meta ) {
var data = this.getJSONNode( meta );
if ( ! data ) {
data = this.createJSONNode( meta );
data.scope = this.scope;
}
return data;
}
}
LightNode.TOTAL = 'total';
LightNode.prototype.nodeType = 'Light';
export { LightNode };