Skip to content

Commit

Permalink
Merge pull request #20077 from Mugen87/dev45
Browse files Browse the repository at this point in the history
Clean up.
  • Loading branch information
mrdoob authored Aug 15, 2020
2 parents 7aa9fa2 + 88b79f2 commit 20b1de2
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 57 deletions.
50 changes: 25 additions & 25 deletions examples/jsm/loaders/3DMLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ Rhino3dmLoader.Rhino3dmWorker = function () {
var views = [];
var namedViews = [];
var groups = [];
var strings = [];

//Handle objects

Expand Down Expand Up @@ -780,7 +779,7 @@ Rhino3dmLoader.Rhino3dmWorker = function () {
position.type = 'Float32Array';
position.array = [ pt[ 0 ], pt[ 1 ], pt[ 2 ] ];

_color = _attributes.drawColor( doc );
var _color = _attributes.drawColor( doc );

color.itemSize = 3;
color.type = 'Float32Array';
Expand Down Expand Up @@ -918,28 +917,28 @@ Rhino3dmLoader.Rhino3dmWorker = function () {

if ( curve instanceof rhino.LineCurve ) {

return [ curve.pointAtStart, curve.pointAtEnd ];
return [ curve.pointAtStart, curve.pointAtEnd ];

}

if ( curve instanceof rhino.PolylineCurve ) {

pointCount = curve.pointCount;
for ( var i = 0; i < pointCount; i ++ ) {
pointCount = curve.pointCount;
for ( var i = 0; i < pointCount; i ++ ) {

rc.push( curve.point( i ) );

}
}

return rc;
return rc;

}

if ( curve instanceof rhino.PolyCurve ) {

var segmentCount = curve.segmentCount;
var segmentCount = curve.segmentCount;

for ( var i = 0; i < segmentCount; i ++ ) {
for ( var i = 0; i < segmentCount; i ++ ) {

var segment = curve.segmentCurve( i );
var segmentArray = curveToPoints( segment );
Expand All @@ -948,13 +947,13 @@ Rhino3dmLoader.Rhino3dmWorker = function () {

}

return rc;
return rc;

}

if ( curve instanceof rhino.NurbsCurve && curve.degree === 1 ) {

// console.info( 'degree 1 curve' );
// console.info( 'degree 1 curve' );

}

Expand All @@ -970,34 +969,35 @@ Rhino3dmLoader.Rhino3dmWorker = function () {
ts.push( t );
continue;

}
}

var tan = curve.tangentAt( t );
var prevTan = curve.tangentAt( ts.slice( - 1 )[ 0 ] );
var tan = curve.tangentAt( t );
var prevTan = curve.tangentAt( ts.slice( - 1 )[ 0 ] );

// Duplicaated from THREE.Vector3
// How to pass imports to worker?
// Duplicaated from THREE.Vector3
// How to pass imports to worker?

tS = tan[ 0 ] * tan[ 0 ] + tan[ 1 ] * tan[ 1 ] + tan[ 2 ] * tan[ 2 ];
ptS = prevTan[ 0 ] * prevTan[ 0 ] + prevTan[ 1 ] * prevTan[ 1 ] + prevTan[ 2 ] * prevTan[ 2 ];
var tS = tan[ 0 ] * tan[ 0 ] + tan[ 1 ] * tan[ 1 ] + tan[ 2 ] * tan[ 2 ];
var ptS = prevTan[ 0 ] * prevTan[ 0 ] + prevTan[ 1 ] * prevTan[ 1 ] + prevTan[ 2 ] * prevTan[ 2 ];

var denominator = Math.sqrt( tS * ptS );
var denominator = Math.sqrt( tS * ptS );

var angle;
var angle;

if ( denominator === 0 ) {
if ( denominator === 0 ) {

angle = Math.PI / 2;

} else {
} else {

var theta = ( tan.x * prevTan.x + tan.y * prevTan.y + tan.z * prevTan.z ) / denominator;
angle = Math.acos( Math.max( - 1, Math.min( 1, theta ) ) );

}
}

if ( angle < 0.1 ) continue;

if ( angle < 0.1 ) continue;
ts.push( t );
ts.push( t );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/loaders/VOXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ VOXLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
}

const chunkSize = data.getInt32( i, true ); i += 4;
const childChunks = data.getInt32( i, true ); i += 4;
data.getInt32( i, true ); i += 4; // childChunks

if ( id === 'SIZE' ) {

Expand Down
3 changes: 1 addition & 2 deletions examples/webgl_loader_3dm.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

loader.load( 'models/3dm/Rhino_Logo.3dm', function ( object ) {

console.log( object );
scene.add( object );
initGUI( object.userData.layers );

Expand Down Expand Up @@ -124,7 +123,7 @@
var layerName = layers[ child.userData.attributes.layerIndex ].name;

if ( layerName === name ) {

child.visible = val;
layer.visible = val;

Expand Down
56 changes: 28 additions & 28 deletions examples/webgl_loader_vox.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,34 +109,34 @@

}

function displayPalette( palette ) {

const canvas = document.createElement( 'canvas' );
canvas.width = 8;
canvas.height = 32;
canvas.style.position = 'absolute';
canvas.style.top = '0';
canvas.style.width = 100 + 'px';
canvas.style.imageRendering = 'pixelated';
document.body.appendChild( canvas );

const context = canvas.getContext( '2d' );

for ( var c = 0; c < 256; c ++ ) {

const x = c % 8;
const y = Math.floor( c / 8 );

const hex = palette[ c + 1 ];
const r = hex >> 0 & 0xff;
const g = hex >> 8 & 0xff;
const b = hex >> 16 & 0xff;
context.fillStyle = `rgba(${r},${g},${b},1)`;
context.fillRect( x, 31 - y, 1, 1 );

}

}
// function displayPalette( palette ) {
//
// const canvas = document.createElement( 'canvas' );
// canvas.width = 8;
// canvas.height = 32;
// canvas.style.position = 'absolute';
// canvas.style.top = '0';
// canvas.style.width = 100 + 'px';
// canvas.style.imageRendering = 'pixelated';
// document.body.appendChild( canvas );
//
// const context = canvas.getContext( '2d' );
//
// for ( var c = 0; c < 256; c ++ ) {
//
// const x = c % 8;
// const y = Math.floor( c / 8 );
//
// const hex = palette[ c + 1 ];
// const r = hex >> 0 & 0xff;
// const g = hex >> 8 & 0xff;
// const b = hex >> 16 & 0xff;
// context.fillStyle = `rgba(${r},${g},${b},1)`;
// context.fillRect( x, 31 - y, 1, 1 );
//
// }
//
// }

function onWindowResize() {

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function WebGLRenderer( parameters ) {
objects = new WebGLObjects( _gl, geometries, attributes, info );
morphtargets = new WebGLMorphtargets( _gl );
programCache = new WebGLPrograms( _this, cubemaps, extensions, capabilities, bindingStates );
materials = new WebGLMaterials( properties, cubemaps );
materials = new WebGLMaterials( properties );
renderLists = new WebGLRenderLists( properties );
renderStates = new WebGLRenderStates();

Expand Down

0 comments on commit 20b1de2

Please sign in to comment.