Archived
Private
Public Access
1
0

Initial commit

This commit is contained in:
2022-09-04 12:45:01 +02:00
commit f4a01d6a69
11601 changed files with 4206660 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import NodeMaterial from './NodeMaterial.js';
import { LineBasicMaterial } from 'three';
const defaultValues = new LineBasicMaterial();
class LineBasicNodeMaterial extends NodeMaterial {
constructor( parameters ) {
super();
this.colorNode = null;
this.opacityNode = null;
this.alphaTestNode = null;
this.lightNode = null;
this.positionNode = null;
this.setDefaultValues( defaultValues );
this.setValues( parameters );
}
copy( source ) {
this.colorNode = source.colorNode;
this.opacityNode = source.opacityNode;
this.alphaTestNode = source.alphaTestNode;
this.lightNode = source.lightNode;
this.positionNode = source.positionNode;
return super.copy( source );
}
}
LineBasicNodeMaterial.prototype.isNodeMaterial = true;
export default LineBasicNodeMaterial;

View File

@@ -0,0 +1,33 @@
import LineBasicNodeMaterial from './LineBasicNodeMaterial.js';
import MeshBasicNodeMaterial from './MeshBasicNodeMaterial.js';
import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js';
import PointsNodeMaterial from './PointsNodeMaterial.js';
import { Material } from 'three';
export {
LineBasicNodeMaterial,
MeshBasicNodeMaterial,
MeshStandardNodeMaterial,
PointsNodeMaterial
};
const materialLib = {
LineBasicNodeMaterial,
MeshBasicNodeMaterial,
MeshStandardNodeMaterial,
PointsNodeMaterial
};
const fromTypeFunction = Material.fromType;
Material.fromType = function ( type ) {
if ( materialLib[ type ] !== undefined ) {
return new materialLib[ type ]();
}
return fromTypeFunction.call( this, type );
};

View File

@@ -0,0 +1,46 @@
import NodeMaterial from './NodeMaterial.js';
import { MeshBasicMaterial } from 'three';
const defaultValues = new MeshBasicMaterial();
class MeshBasicNodeMaterial extends NodeMaterial {
constructor( parameters ) {
super();
this.colorNode = null;
this.opacityNode = null;
this.alphaTestNode = null;
this.lightNode = null;
this.positionNode = null;
this.setDefaultValues( defaultValues );
this.setValues( parameters );
}
copy( source ) {
this.colorNode = source.colorNode;
this.opacityNode = source.opacityNode;
this.alphaTestNode = source.alphaTestNode;
this.lightNode = source.lightNode;
this.positionNode = source.positionNode;
return super.copy( source );
}
}
MeshBasicNodeMaterial.prototype.isNodeMaterial = true;
export default MeshBasicNodeMaterial;

View File

@@ -0,0 +1,68 @@
import NodeMaterial from './NodeMaterial.js';
import { MeshStandardMaterial } from 'three';
const defaultValues = new MeshStandardMaterial();
export default class MeshStandardNodeMaterial extends NodeMaterial {
constructor( parameters ) {
super();
this.colorNode = null;
this.opacityNode = null;
this.alphaTestNode = null;
this.normalNode = null;
this.emissiveNode = null;
this.metalnessNode = null;
this.roughnessNode = null;
this.clearcoatNode = null;
this.clearcoatRoughnessNode = null;
this.envNode = null;
this.lightNode = null;
this.positionNode = null;
this.setDefaultValues( defaultValues );
this.setValues( parameters );
}
copy( source ) {
this.colorNode = source.colorNode;
this.opacityNode = source.opacityNode;
this.alphaTestNode = source.alphaTestNode;
this.normalNode = source.normalNode;
this.emissiveNode = source.emissiveNode;
this.metalnessNode = source.metalnessNode;
this.roughnessNode = source.roughnessNode;
this.clearcoatNode = source.clearcoatNode;
this.clearcoatRoughnessNode = source.clearcoatRoughnessNode;
this.envNode = source.envNode;
this.lightNode = source.lightNode;
this.positionNode = source.positionNode;
return super.copy( source );
}
}
MeshStandardNodeMaterial.prototype.isNodeMaterial = true;

View File

@@ -0,0 +1,98 @@
import { Material, ShaderMaterial } from 'three';
import { getNodesKeys } from '../core/NodeUtils.js';
class NodeMaterial extends ShaderMaterial {
constructor() {
super();
this.type = this.constructor.name;
this.lights = true;
}
setDefaultValues( values ) {
// This approach is to reuse the native refreshUniforms*
// and turn available the use of features like transmission and environment in core
for ( const property in values ) {
if ( this[ property ] === undefined ) {
this[ property ] = values[ property ];
}
}
Object.assign( this.defines, values.defines );
}
toJSON( meta ) {
const isRoot = ( meta === undefined || typeof meta === 'string' );
if ( isRoot ) {
meta = {
textures: {},
images: {},
nodes: {}
};
}
const data = Material.prototype.toJSON.call( this, meta );
const nodeKeys = getNodesKeys( this );
data.inputNodes = {};
for ( const name of nodeKeys ) {
data.inputNodes[ name ] = this[ name ].toJSON( meta ).uuid;
}
// TODO: Copied from Object3D.toJSON
function extractFromCache( cache ) {
const values = [];
for ( const key in cache ) {
const data = cache[ key ];
delete data.metadata;
values.push( data );
}
return values;
}
if ( isRoot ) {
const textures = extractFromCache( meta.textures );
const images = extractFromCache( meta.images );
const nodes = extractFromCache( meta.nodes );
if ( textures.length > 0 ) data.textures = textures;
if ( images.length > 0 ) data.images = images;
if ( nodes.length > 0 ) data.nodes = nodes;
}
return data;
}
}
NodeMaterial.prototype.isNodeMaterial = true;
export default NodeMaterial;

View File

@@ -0,0 +1,50 @@
import NodeMaterial from './NodeMaterial.js';
import { PointsMaterial } from 'three';
const defaultValues = new PointsMaterial();
class PointsNodeMaterial extends NodeMaterial {
constructor( parameters ) {
super();
this.colorNode = null;
this.opacityNode = null;
this.alphaTestNode = null;
this.lightNode = null;
this.sizeNode = null;
this.positionNode = null;
this.setDefaultValues( defaultValues );
this.setValues( parameters );
}
copy( source ) {
this.colorNode = source.colorNode;
this.opacityNode = source.opacityNode;
this.alphaTestNode = source.alphaTestNode;
this.lightNode = source.lightNode;
this.sizeNode = source.sizeNode;
this.positionNode = source.positionNode;
return super.copy( source );
}
}
PointsNodeMaterial.prototype.isNodeMaterial = true;
export default PointsNodeMaterial;