Skip to content

Commit

Permalink
add GeometryUtils.mergeGeometries
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn0326 committed Apr 2, 2020
1 parent c286e49 commit 388c9b5
Show file tree
Hide file tree
Showing 20 changed files with 2,780 additions and 14 deletions.
83 changes: 83 additions & 0 deletions build/zen3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -7286,6 +7286,89 @@
*/
dispose: function() {
this.dispatchEvent({ type: 'dispose' });
},

/**
* Copies another Geometry to this Geometry.
* @param {zen3d.Geometry} source - The geometry to be copied.
* @return {zen3d.Geometry}
*/
copy: function(source) {
var name, i, l;

// reset

this.index = null;
this.attributes = {};
this.morphAttributes = {};
this.groups = [];
this.boundingBox = null;
this.boundingSphere = null;

// index

var index = source.index;

if (index !== null) {
this.setIndex(index.clone());
}

// attributes

var attributes = source.attributes;

for (name in attributes) {
var attribute = attributes[name];
this.addAttribute(name, attribute.clone());
}

// morph attributes

var morphAttributes = source.morphAttributes;

for (name in morphAttributes) {
var array = [];
var morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes

for (i = 0, l = morphAttribute.length; i < l; i++) {
array.push(morphAttribute[i].clone());
}

this.morphAttributes[name] = array;
}

// groups

var groups = source.groups;

for (i = 0, l = groups.length; i < l; i++) {
var group = groups[i];
this.addGroup(group.start, group.count, group.materialIndex);
}

var boundingBox = source.boundingBox;

if (boundingBox !== null) {
this.boundingBox = new Box3().copy(boundingBox);
}

// bounding sphere

var boundingSphere = source.boundingSphere;

if (boundingSphere !== null) {
this.boundingSphere = new Sphere().copy(boundingSphere);
}

return this;
},

/**
* Creates a clone of this Geometry.
* @return {zen3d.Geometry}
*/
clone: function clone() {
return new Geometry().copy(this);
}

});
Expand Down
2 changes: 1 addition & 1 deletion build/zen3d.min.js

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions build/zen3d.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7280,6 +7280,89 @@ Geometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), /**
*/
dispose: function() {
this.dispatchEvent({ type: 'dispose' });
},

/**
* Copies another Geometry to this Geometry.
* @param {zen3d.Geometry} source - The geometry to be copied.
* @return {zen3d.Geometry}
*/
copy: function(source) {
var name, i, l;

// reset

this.index = null;
this.attributes = {};
this.morphAttributes = {};
this.groups = [];
this.boundingBox = null;
this.boundingSphere = null;

// index

var index = source.index;

if (index !== null) {
this.setIndex(index.clone());
}

// attributes

var attributes = source.attributes;

for (name in attributes) {
var attribute = attributes[name];
this.addAttribute(name, attribute.clone());
}

// morph attributes

var morphAttributes = source.morphAttributes;

for (name in morphAttributes) {
var array = [];
var morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes

for (i = 0, l = morphAttribute.length; i < l; i++) {
array.push(morphAttribute[i].clone());
}

this.morphAttributes[name] = array;
}

// groups

var groups = source.groups;

for (i = 0, l = groups.length; i < l; i++) {
var group = groups[i];
this.addGroup(group.start, group.count, group.materialIndex);
}

var boundingBox = source.boundingBox;

if (boundingBox !== null) {
this.boundingBox = new Box3().copy(boundingBox);
}

// bounding sphere

var boundingSphere = source.boundingSphere;

if (boundingSphere !== null) {
this.boundingSphere = new Sphere().copy(boundingSphere);
}

return this;
},

/**
* Creates a clone of this Geometry.
* @return {zen3d.Geometry}
*/
clone() {
return new Geometry().copy(this);
}

});
Expand Down
83 changes: 83 additions & 0 deletions docs/geometry_Geometry.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,89 @@ <h1 class="page-title">Source: geometry/Geometry.js</h1>
*/
dispose: function() {
this.dispatchEvent({ type: 'dispose' });
},

/**
* Copies another Geometry to this Geometry.
* @param {zen3d.Geometry} source - The geometry to be copied.
* @return {zen3d.Geometry}
*/
copy: function(source) {
var name, i, l;

// reset

this.index = null;
this.attributes = {};
this.morphAttributes = {};
this.groups = [];
this.boundingBox = null;
this.boundingSphere = null;

// index

var index = source.index;

if (index !== null) {
this.setIndex(index.clone());
}

// attributes

var attributes = source.attributes;

for (name in attributes) {
var attribute = attributes[name];
this.addAttribute(name, attribute.clone());
}

// morph attributes

var morphAttributes = source.morphAttributes;

for (name in morphAttributes) {
var array = [];
var morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes

for (i = 0, l = morphAttribute.length; i &lt; l; i++) {
array.push(morphAttribute[i].clone());
}

this.morphAttributes[name] = array;
}

// groups

var groups = source.groups;

for (i = 0, l = groups.length; i &lt; l; i++) {
var group = groups[i];
this.addGroup(group.start, group.count, group.materialIndex);
}

var boundingBox = source.boundingBox;

if (boundingBox !== null) {
this.boundingBox = new Box3().copy(boundingBox);
}

// bounding sphere

var boundingSphere = source.boundingSphere;

if (boundingSphere !== null) {
this.boundingSphere = new Sphere().copy(boundingSphere);
}

return this;
},

/**
* Creates a clone of this Geometry.
* @return {zen3d.Geometry}
*/
clone() {
return new Geometry().copy(this);
}

});
Expand Down
11 changes: 11 additions & 0 deletions docs/math_Vector3.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ <h1 class="page-title">Source: math/Vector3.js</h1>

/**
*
*/
addScaledVector: function (v, s) {
this.x += v.x * s;
this.y += v.y * s;
this.z += v.z * s;

return this;
},

/**
*
*/
subVectors: function(a, b) {
this.x = a.x - b.x;
Expand Down
Loading

0 comments on commit 388c9b5

Please sign in to comment.