Skip to content

Commit

Permalink
Some objects can share a single geometry instance
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchirls committed May 21, 2015
1 parent 5d5fa19 commit af557d9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 54 deletions.
62 changes: 31 additions & 31 deletions build/vr.dev.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions build/vr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/vr.js.map

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/objects/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ module.exports = (function () {
'use strict';

var materials = require('../materials'),
THREE = require('three');
THREE = require('three'),
geometry = new THREE.BoxGeometry( 1, 1, 1 );

return function box(parent, options) {
var geometry,
mesh;
var mesh;

geometry = new THREE.BoxGeometry( 1, 1, 1 );
mesh = new THREE.Mesh(geometry, materials.standard());
mesh.name = 'box';

Expand Down
15 changes: 7 additions & 8 deletions src/objects/panorama.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ module.exports = (function () {
'use strict';

var materials = require('../materials'),
THREE = require('three');
THREE = require('three'),
geometry = new THREE.SphereGeometry(1000, 60, 60);

geometry.applyMatrix(new THREE.Matrix4().makeScale(-1, 1, 1));
geometry.applyMatrix(new THREE.Matrix4().makeRotationY(- Math.PI / 2));

return function panorama(parent, options) {
var geometry,
material,
var material,
mesh,
src,
tex;
Expand All @@ -21,16 +24,12 @@ module.exports = (function () {
tex = materials.imageTexture(src, THREE.UVMapping);
}

geometry = new THREE.SphereGeometry(1000, 60, 60);
geometry.applyMatrix(new THREE.Matrix4().makeScale(-1, 1, 1));
geometry.applyMatrix(new THREE.Matrix4().makeRotationY(- Math.PI / 2));

material = new THREE.MeshBasicMaterial({
transparent: true,
map: tex
});

mesh = new THREE.Mesh( geometry, material );
mesh = new THREE.Mesh(geometry, material);

if (options && options.stereo) {
if (options.stereo === 'vertical') {
Expand Down
6 changes: 2 additions & 4 deletions src/objects/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ module.exports = (function () {
fontSizeRegex = /(\d+)px/i,
newLineRegex = /[\n\r]/,
spaceRegex = /[\t ]/,
log2 = Math.log(2);
log2 = Math.log(2),
geometry = new THREE.PlaneBufferGeometry(1, 1);

return function text(parent, options) {
var self = this,
geometry,
material,
canvas,
ctx,
Expand Down Expand Up @@ -242,8 +242,6 @@ module.exports = (function () {
tex.generateMipmaps = true;
}

geometry = new THREE.PlaneBufferGeometry(1, 1);

material = new THREE.MeshBasicMaterial({
side: THREE.DoubleSide,
transparent: true,
Expand Down

0 comments on commit af557d9

Please sign in to comment.