Skip to content

Commit

Permalink
update three.js to latest version of three-depthtextures.js
Browse files Browse the repository at this point in the history
 - split some GLSL shader to separate files
  • Loading branch information
nraynaud committed Sep 26, 2015
1 parent b75dc6a commit 18ea153
Show file tree
Hide file tree
Showing 15 changed files with 22,426 additions and 20,386 deletions.
Binary file added images/IO_interface_schem.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/IO_interface_schem_thumb.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions various_tests/test_3D.html
Expand Up @@ -256,15 +256,14 @@
if (points)
return new THREE.PointCloud(geometry, terrainMaterial);
else
return new THREE.Line(geometry, terrainMaterial, THREE.LinePieces);
return new THREE.LineSegments(geometry, terrainMaterial);
}

var grid = createGrid(pipeline.toolPosBuffer.width, pipeline.toolPosBuffer.height, false, false, true);
grid.frustumCulled = false;
scene2.add(grid);
scene2.add(new THREE.Mesh(clonedGeometry, new THREE.MeshLambertMaterial({
color: 0xFEEFFE,
shading: THREE.SmoothShading
color: 0xFEEFFE
})));

document.documentElement.addEventListener('keydown', function (event) {
Expand Down
3 changes: 0 additions & 3 deletions various_tests/test_3D_conservative_rendering.html
Expand Up @@ -235,13 +235,11 @@
scene2.add(grid);
scene2.add(new THREE.Mesh(clonedGeometry, new THREE.MeshLambertMaterial({
color: 0xFEEFFE,
shading: THREE.SmoothShading,
side: THREE.DoubleSide
})));

scene2.add(new THREE.PointCloud(pipeline.modelStage.inputGeometry.clone(), new THREE.ShaderMaterial({
depthTest: true,
sizeAttenuation: false,
uniforms: pipeline.modelStage.shaderUniforms,
attributes: pipeline.modelStage.shaderAttributes,
vertexShader: pipeline.modelStage.vertexShader,
Expand All @@ -253,7 +251,6 @@

scene2.add(new THREE.Line(pipeline.modelStage.inputGeometry.clone(), new THREE.ShaderMaterial({
depthTest: true,
sizeAttenuation: false,
uniforms: pipeline.modelStage.shaderUniforms,
attributes: pipeline.modelStage.shaderAttributes,
vertexShader: pipeline.modelStage.vertexShader,
Expand Down
12 changes: 4 additions & 8 deletions webapp/cnc/app/view.js
Expand Up @@ -221,16 +221,13 @@ define(['Ember', 'cnc/svgImporter', 'cnc/gerberImporter', 'cnc/excellonImporter'
});
this.set('nativeComponent', threeDView);
this.set('travelDisplay', threeDView.createDrawingNode(threeDView.rapidMaterial, new THREE.MeshLambertMaterial({
color: 0xFEEFFE,
shading: THREE.SmoothShading
color: 0xFEEFFE
})));
this.set('outlinesDisplay', threeDView.createDrawingNode(threeDView.outlineMaterial, new THREE.MeshLambertMaterial({
color: 0xFEEFFE,
shading: THREE.SmoothShading
color: 0xFEEFFE
})));
this.set('highlightDisplay', threeDView.createOverlayNode(threeDView.highlightMaterial, new THREE.MeshLambertMaterial({
color: 0xdd4c2f, opacity: 0.5,
shading: THREE.SmoothShading
color: 0xdd4c2f, opacity: 0.5
})));

this.synchronizeCurrentOperation();
Expand All @@ -241,8 +238,7 @@ define(['Ember', 'cnc/svgImporter', 'cnc/gerberImporter', 'cnc/excellonImporter'
return ShapeWrapper.create({
shape: shape,
outlineDisplay: threeDView.createDrawingNode(threeDView.outlineMaterial, new THREE.MeshLambertMaterial({
color: 0xFEEFFE,
shading: THREE.SmoothShading
color: 0xFEEFFE
}))
});
}
Expand Down
354 changes: 129 additions & 225 deletions webapp/cnc/cam/3D/modelProjector.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions webapp/cnc/gcode/simulation.js
Expand Up @@ -241,8 +241,6 @@ define(['cnc/util', 'cnc/gcode/geometry'], function (util, geometry) {

function discretize(segment) {
var type = COMPONENT_TYPES[segment.type];

console.log(segment.type, type);
var steps = type.simulationSteps(segment);
var startTime = currentTime;
for (var j = 1; j <= steps; j++) {
Expand Down
12 changes: 6 additions & 6 deletions webapp/cnc/ui/threeDView.js
Expand Up @@ -74,7 +74,7 @@ define(['THREE', 'TWEEN', 'cnc/util', 'libs/threejs/OrbitControls', 'cnc/ui/cube
var res = earcut(rawVertices, [], 3);
var bufferedGeometry = new THREE.BufferGeometry();
bufferedGeometry.addAttribute('position', new THREE.BufferAttribute(rawVertices, 3));
bufferedGeometry.addAttribute('index', new THREE.BufferAttribute(new Uint16Array(res), 1));
bufferedGeometry.setIndex(new THREE.BufferAttribute(new Uint16Array(res), 1));
this.node.add(new THREE.Mesh(bufferedGeometry, this.meshMaterial));
}
},
Expand Down Expand Up @@ -113,14 +113,14 @@ define(['THREE', 'TWEEN', 'cnc/util', 'libs/threejs/OrbitControls', 'cnc/ui/cube
if (this.bufferedGeometry == null) {
this.bufferedGeometry = new THREE.BufferGeometry();
this.bufferedGeometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
this.bufferedGeometry.addAttribute('index', new THREE.BufferAttribute(newIndices, 1));
this.node.add(new THREE.Line(this.bufferedGeometry, this.lineMaterial, THREE.LinePieces));
this.bufferedGeometry.setIndex(new THREE.BufferAttribute(newIndices, 1));
this.node.add(new THREE.LineSegments(this.bufferedGeometry, this.lineMaterial));
} else {
var attributes = this.bufferedGeometry.attributes;
attributes.position.array = typedArrayConcat(attributes.position.array, vertices, Float32Array);
attributes.index.array = typedArrayConcat(attributes.index.array, newIndices, Uint16Array);
this.bufferedGeometry.index.array = typedArrayConcat(this.bufferedGeometry.index.array, newIndices, Uint16Array);
attributes.position.needsUpdate = true;
attributes.index.needsUpdate = true;
this.bufferedGeometry.index.needsUpdate = true;
}
}
};
Expand Down Expand Up @@ -247,7 +247,7 @@ define(['THREE', 'TWEEN', 'cnc/util', 'libs/threejs/OrbitControls', 'cnc/ui/cube
this.requestAnimationFrameCallback = this.actuallyRender.bind(this);
$container.prepend(cubeManipulator(this));
$container.prepend($('<div class="3DWarning" title="maybe one day" style="position:absolute; top:0; right: 0;">Sorry, there is no mouse selection in this view.</div>'));
this.rapidToolpathNode = this.createDrawingNode(this.rapidMaterial);
this.rapidToolpathNode = this.createOverlayNode(this.rapidMaterial);
this.normalToolpathNode = this.createDrawingNode(this.normalMaterial, new THREE.MeshBasicMaterial({
color: 0x6622BB,
opacity: 0.5,
Expand Down
56 changes: 28 additions & 28 deletions webapp/libs/threejs/postprocessing/ShaderPass.js
Expand Up @@ -2,57 +2,57 @@
* @author alteredq / http://alteredqualia.com/
*/

THREE.ShaderPass = function (shader, textureID) {
THREE.ShaderPass = function ( shader, textureID ) {

this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";
this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";

this.uniforms = THREE.UniformsUtils.clone(shader.uniforms);
this.material = new THREE.ShaderMaterial({
this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );

defines: shader.defines || {},
uniforms: this.uniforms,
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader
this.material = new THREE.ShaderMaterial( {

});
uniforms: this.uniforms,
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader

this.renderToScreen = false;
} );

this.enabled = true;
this.needsSwap = true;
this.clear = false;
this.renderToScreen = false;

this.enabled = true;
this.needsSwap = true;
this.clear = false;

this.camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
this.scene = new THREE.Scene();

this.quad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2), null);
this.scene.add(this.quad);
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
this.scene = new THREE.Scene();

this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
this.scene.add( this.quad );

};

THREE.ShaderPass.prototype = {

render: function (renderer, writeBuffer, readBuffer, delta) {
render: function ( renderer, writeBuffer, readBuffer, delta ) {

if (this.uniforms[ this.textureID ]) {
if ( this.uniforms[ this.textureID ] ) {

this.uniforms[ this.textureID ].value = readBuffer;
this.uniforms[ this.textureID ].value = readBuffer;

}
}

this.quad.material = this.material;
this.quad.material = this.material;

if (this.renderToScreen) {
if ( this.renderToScreen ) {

renderer.render(this.scene, this.camera);
renderer.render( this.scene, this.camera );

} else {
} else {

renderer.render(this.scene, this.camera, writeBuffer, this.clear);
renderer.render( this.scene, this.camera, writeBuffer, this.clear );

}
}

}
}

};

0 comments on commit 18ea153

Please sign in to comment.