Commit f51e0ea1 authored by wjf's avatar wjf

l

parent b9e50b49
...@@ -140,6 +140,9 @@ export class D3Renderer extends ObjectRenderer { ...@@ -140,6 +140,9 @@ export class D3Renderer extends ObjectRenderer {
} }
//有索引 //有索引
if (geo._indices) glVaoBuffer.indexBuffer = GLBuffer.createIndexBuffer(gl, null, gl.STATIC_DRAW); if (geo._indices) glVaoBuffer.indexBuffer = GLBuffer.createIndexBuffer(gl, null, gl.STATIC_DRAW);
//有变形顶点
//有变形法线
//计算一次,打包所有的顶点属性 //计算一次,打包所有的顶点属性
const float32View = geo._attrBuffer.float32View; const float32View = geo._attrBuffer.float32View;
...@@ -187,6 +190,10 @@ export class D3Renderer extends ObjectRenderer { ...@@ -187,6 +190,10 @@ export class D3Renderer extends ObjectRenderer {
if (attrs.aNormal) vao.addAttribute(glVaoBuffer.attrBuffer, attrs.aNormal, gl.FLOAT, false, geo._vertByteSize, 8 * 4); if (attrs.aNormal) vao.addAttribute(glVaoBuffer.attrBuffer, attrs.aNormal, gl.FLOAT, false, geo._vertByteSize, 8 * 4);
//索引看情况加 //索引看情况加
if (geo._indices) vao.addIndex(glVaoBuffer.indexBuffer); if (geo._indices) vao.addIndex(glVaoBuffer.indexBuffer);
//变形顶点
//变形法线
// 首次需要绑定buffer到vao // 首次需要绑定buffer到vao
this.renderer.bindVao(vao); this.renderer.bindVao(vao);
//需要分别绑定 //需要分别绑定
...@@ -199,7 +206,7 @@ export class D3Renderer extends ObjectRenderer { ...@@ -199,7 +206,7 @@ export class D3Renderer extends ObjectRenderer {
// glVaoBuffer.attrBuffer.upload(glVaoBuffer._attrBuffer.vertices, 0, true) // glVaoBuffer.attrBuffer.upload(glVaoBuffer._attrBuffer.vertices, 0, true)
// glVaoBuffer.indexBuffer.upload(glVaoBuffer._indexBuffer, 0, true) // glVaoBuffer.indexBuffer.upload(glVaoBuffer._indexBuffer, 0, true)
//变形的数据可能传入的会改变,所以需要upload //变形的数据可能传入的会改变,所以需要upload
} }
//根据材质切换渲染面 //根据材质切换渲染面
if (mat.side == RenderSideType.DoubleSide) { if (mat.side == RenderSideType.DoubleSide) {
......
...@@ -14,11 +14,18 @@ const tempRay: Ray = new Ray(); ...@@ -14,11 +14,18 @@ const tempRay: Ray = new Ray();
const tempPoint = new Vector3(); const tempPoint = new Vector3();
export class Mesh3D extends Object3D { export class Mesh3D extends Object3D {
/**
* 外部可设置
* 用于变形权重,
*
*/
public morphTargetInfluences: number[];
constructor( constructor(
public geometry: Geometry, public geometry: Geometry,
public material: BaseMaterial public material: BaseMaterial
) { ) {
super(); super();
} }
_render(renderer) { _render(renderer) {
if (!this.visible) return if (!this.visible) return
...@@ -26,6 +33,40 @@ export class Mesh3D extends Object3D { ...@@ -26,6 +33,40 @@ export class Mesh3D extends Object3D {
renderer.plugins["d3"].render(this) renderer.plugins["d3"].render(this)
} }
updateMorphTargets() {
// var geometry = this.geometry;
// var m, ml, name;
// var morphAttributes = geometry.morphAttributes;
// var keys = Object.keys(morphAttributes);
// if (keys.length > 0) {
// var morphAttribute = morphAttributes[keys[0]];
// if (morphAttribute !== undefined) {
// this.morphTargetInfluences = [];
// this.morphTargetDictionary = {};
// for (m = 0, ml = morphAttribute.length; m < ml; m++) {
// name = morphAttribute[m].name || String(m);
// this.morphTargetInfluences.push(0);
// this.morphTargetDictionary[name] = m;
// }
// }
// }
}
raycast(raycaster: Raycaster, intersects: IntersectData[]) { raycast(raycaster: Raycaster, intersects: IntersectData[]) {
if (!this.visible || !this.geometry || !this.material || this.material.wireframe) return; if (!this.visible || !this.geometry || !this.material || this.material.wireframe) return;
var geometry = this.geometry; var geometry = this.geometry;
...@@ -105,6 +146,13 @@ export class Mesh3D extends Object3D { ...@@ -105,6 +146,13 @@ export class Mesh3D extends Object3D {
} }
} }
}; };
/**
*
*/
clone() {
return new Mesh3D(this.geometry, this.material).copy(this);
}
} }
......
...@@ -56,7 +56,7 @@ function getShaderKey(parameters: ShaderParametersInt) { ...@@ -56,7 +56,7 @@ function getShaderKey(parameters: ShaderParametersInt) {
class CusShader extends GLShader { class CusShader extends GLShader {
/** /**
* 以后回收时用 * 以后回收时用TODO
*/ */
usedTimes: number; usedTimes: number;
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment