提交 9f57ad82 编写于 作者: A alteredq

Editor: removed dummy textures.

Experimenting with "geometry.buffersNeedUpdate".
上级 2e6fa9c7
......@@ -4886,7 +4886,7 @@ THREE.Geometry = function () {
this.hasTangents = false;
this.dynamic = true; // the intermediate typearrays will be deleted when set to false
this.dynamic = true; // the intermediate typed arrays will be deleted when set to false
// update flags
......@@ -4897,6 +4897,8 @@ THREE.Geometry = function () {
this.tangentsNeedUpdate = false;
this.colorsNeedUpdate = false;
this.buffersNeedUpdate = false;
};
THREE.Geometry.prototype = {
......@@ -19894,6 +19896,12 @@ THREE.WebGLRenderer = function ( parameters ) {
material = getBufferMaterial( object, geometryGroup );
if ( geometry.buffersNeedUpdate ) {
initMeshBuffers( geometryGroup, object );
}
customAttributesDirty = material.attributes && areCustomAttributesDirty( material );
if ( geometry.verticesNeedUpdate || geometry.morphTargetsNeedUpdate || geometry.elementsNeedUpdate ||
......@@ -19914,6 +19922,8 @@ THREE.WebGLRenderer = function ( parameters ) {
geometry.colorsNeedUpdate = false;
geometry.tangentsNeedUpdate = false;
geometry.buffersNeedUpdate = false;
material.attributes && clearCustomAttributes( material );
}
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -85,16 +85,6 @@
//
var canvas = document.createElement( 'canvas' );
var context = canvas.getContext( '2d' );
context.fillStyle = 'rgb(255,255,255)';
context.fillRect( 0, 0, canvas.width, canvas.height );
var dummyTexture = new THREE.Texture( canvas );
dummyTexture.needsUpdate = true;
//
var menubar = new Menubar( signals );
menubar.setWidth( '100%' );
menubar.setHeight( '32px' );
......@@ -184,7 +174,6 @@
loader.parse( xml, function ( collada ) {
collada.scene.name = filename;
applyDummyTexture( collada.scene );
signals.objectAdded.dispatch( collada.scene );
signals.objectSelected.dispatch( collada.scene );
......@@ -268,7 +257,6 @@
var object = new THREE.OBJLoader().parse( contents );
object.name = filename;
applyDummyTexture( object );
signals.objectAdded.dispatch( object );
signals.objectSelected.dispatch( object );
......@@ -345,7 +333,7 @@
var geometry = new THREE.SphereGeometry( 75, 25, 15 );
var color = Math.random() * 0xffffff;
var material = new THREE.MeshLambertMaterial( { color: color, ambient: color, map: dummyTexture } );
var material = new THREE.MeshLambertMaterial( { color: color, ambient: color } );
var mesh = new THREE.Mesh( geometry, material );
mesh.name = "Sphere";
......@@ -361,26 +349,7 @@
var createDummyMaterial = function ( geometry ) {
var material = new THREE.MeshLambertMaterial();
if ( geometry.faceVertexUvs[ 0 ].length > 0 )
material.map = dummyTexture;
return material;
};
var applyDummyTexture = function ( root ) {
root.traverse( function ( node ) {
if ( node.material && node.geometry.faceVertexUvs[ 0 ].length > 0 ) {
node.material.map = dummyTexture;
}
} );
return new THREE.MeshLambertMaterial();
};
......
......@@ -6,7 +6,8 @@ UI.Texture = function ( position ) {
var scope = this;
this.texture = new THREE.Texture();
var image = new Image();
this.texture = new THREE.Texture( image );
this.dom = document.createElement( 'input' );
this.dom.type = 'file';
......
......@@ -220,14 +220,6 @@ Sidebar.Properties.Material = function ( signals ) {
var selected = null;
var selectedHasUvs = false;
var canvas = document.createElement( 'canvas' );
var context = canvas.getContext( '2d' );
context.fillStyle = 'rgb(255,255,255)';
context.fillRect( 0, 0, canvas.width, canvas.height );
var dummyTexture = new THREE.Texture( canvas );
dummyTexture.needsUpdate = true;
function update() {
var material = selected.material;
......@@ -242,12 +234,6 @@ Sidebar.Properties.Material = function ( signals ) {
material = new materials[ materialClass.getValue() ]();
selected.material = material;
if ( selectedHasUvs ) {
material.map = dummyTexture;
}
}
if ( material.color !== undefined ) {
......@@ -286,8 +272,10 @@ Sidebar.Properties.Material = function ( signals ) {
if ( selectedHasUvs ) {
material.map = mapEnabled ? materialMap.getValue() : dummyTexture;
material.map = mapEnabled ? materialMap.getValue() : null;
material.needsUpdate = true;
selected.geometry.buffersNeedUpdate = true;
selected.geometry.uvsNeedUpdate = true;
} else {
......@@ -306,6 +294,8 @@ Sidebar.Properties.Material = function ( signals ) {
material.lightMap = lightMapEnabled ? materialLightMap.getValue() : null;
material.needsUpdate = true;
selected.geometry.buffersNeedUpdate = true;
selected.geometry.uvsNeedUpdate = true;
} else {
......@@ -325,6 +315,8 @@ Sidebar.Properties.Material = function ( signals ) {
material.bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
material.bumpScale = materialBumpScale.getValue();
material.needsUpdate = true;
selected.geometry.buffersNeedUpdate = true;
selected.geometry.uvsNeedUpdate = true;
} else {
......@@ -342,6 +334,8 @@ Sidebar.Properties.Material = function ( signals ) {
material.normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
material.needsUpdate = true;
selected.geometry.buffersNeedUpdate = true;
selected.geometry.uvsNeedUpdate = true;
} else {
......@@ -359,6 +353,8 @@ Sidebar.Properties.Material = function ( signals ) {
material.specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
material.needsUpdate = true;
selected.geometry.buffersNeedUpdate = true;
selected.geometry.uvsNeedUpdate = true;
} else {
......@@ -377,6 +373,8 @@ Sidebar.Properties.Material = function ( signals ) {
material.envMap = envMapEnabled ? materialEnvMap.getValue() : null;
material.reflectivity = materialReflectivity.getValue();
material.needsUpdate = true;
selected.geometry.buffersNeedUpdate = true;
selected.geometry.uvsNeedUpdate = true;
} else {
......@@ -520,7 +518,6 @@ Sidebar.Properties.Material = function ( signals ) {
} else {
materialMapEnabled.setValue( false );
materialMap.setValue( dummyTexture );
}
......
......@@ -36,7 +36,7 @@ THREE.Geometry = function () {
this.hasTangents = false;
this.dynamic = true; // the intermediate typearrays will be deleted when set to false
this.dynamic = true; // the intermediate typed arrays will be deleted when set to false
// update flags
......@@ -47,6 +47,8 @@ THREE.Geometry = function () {
this.tangentsNeedUpdate = false;
this.colorsNeedUpdate = false;
this.buffersNeedUpdate = false;
};
THREE.Geometry.prototype = {
......
......@@ -838,7 +838,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if( !attribute.__webglInitialized || attribute.createUniqueBuffers ) {
if ( !attribute.__webglInitialized || attribute.createUniqueBuffers ) {
attribute.__webglInitialized = true;
......@@ -4359,6 +4359,12 @@ THREE.WebGLRenderer = function ( parameters ) {
material = getBufferMaterial( object, geometryGroup );
if ( geometry.buffersNeedUpdate ) {
initMeshBuffers( geometryGroup, object );
}
customAttributesDirty = material.attributes && areCustomAttributesDirty( material );
if ( geometry.verticesNeedUpdate || geometry.morphTargetsNeedUpdate || geometry.elementsNeedUpdate ||
......@@ -4379,6 +4385,8 @@ THREE.WebGLRenderer = function ( parameters ) {
geometry.colorsNeedUpdate = false;
geometry.tangentsNeedUpdate = false;
geometry.buffersNeedUpdate = false;
material.attributes && clearCustomAttributes( material );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册