mirror of https://gitee.com/cf-fz/WebCAD.git
parent
f524b54190
commit
7de39ba93e
@ -0,0 +1,61 @@
|
||||
import * as THREE from 'three';
|
||||
import { Vector3 } from 'three';
|
||||
|
||||
|
||||
|
||||
//绘制线
|
||||
function DrawLine(sp: THREE.Vector3, ep: THREE.Vector3): THREE.Object3D
|
||||
{
|
||||
//创建几何体
|
||||
var geometry = new THREE.Geometry();
|
||||
geometry.vertices.push(sp.clone());
|
||||
geometry.vertices.push(ep.clone());
|
||||
|
||||
//创建材质
|
||||
var material = new THREE.LineBasicMaterial();
|
||||
let threeObject: THREE.Object3D = new THREE.Line(geometry, material);
|
||||
|
||||
return threeObject;
|
||||
}
|
||||
|
||||
function SetLinePoint(line: THREE.Object3D, pt: THREE.Vector3)
|
||||
{
|
||||
let l: THREE.Line = <THREE.Line>line;
|
||||
|
||||
let geo: THREE.Geometry = <THREE.Geometry>l.geometry;
|
||||
|
||||
geo.vertices[0].set(pt.x, pt.y, pt.z);
|
||||
|
||||
geo.verticesNeedUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {THREE.Object3D} ent
|
||||
* @param {boolean} isSet
|
||||
*/
|
||||
function SetIsSelect(ent: THREE.Object3D, isSet: boolean)
|
||||
{
|
||||
var baseColor = 0x333333;
|
||||
var foundColor = 0x12C0E3;
|
||||
var intersectColor = 0x00D66B;
|
||||
|
||||
let mesh = <THREE.Mesh>ent;
|
||||
|
||||
let material = <THREE.MeshBasicMaterial>mesh.material;
|
||||
|
||||
if (isSet)
|
||||
{
|
||||
material.color.setHex(intersectColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.color.setHex(baseColor);
|
||||
}
|
||||
}
|
||||
|
||||
function CreateBox(l: number, w: number, h: number)
|
||||
{
|
||||
var geometry = new THREE.BoxGeometry(l, w, h);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 场景的渲染类型.
|
||||
*
|
||||
* @export
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum RenderType
|
||||
{
|
||||
/**
|
||||
* 线框模式
|
||||
*/
|
||||
Wireframe = 1
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
import { Viewer } from './Viewer';
|
||||
import * as xaop from 'xaop';
|
||||
import Stats = require('stats.js')
|
||||
|
||||
|
||||
/**
|
||||
* 渲染性能状态查看器. 在DOM上显示一个渲染帧数
|
||||
*
|
||||
* @export
|
||||
* @class RenderPerformanceStatus
|
||||
*/
|
||||
export class RenderPerformanceStatus
|
||||
{
|
||||
m_Stats: Stats;
|
||||
constructor(view: Viewer)
|
||||
{
|
||||
this.m_Stats = new Stats();
|
||||
this.m_Stats.showPanel(0);
|
||||
this.m_Stats.dom.style.top = "36px";
|
||||
document.body.appendChild(this.m_Stats.dom);
|
||||
|
||||
//aop注入.
|
||||
|
||||
xaop.begin(view, view.Render, () =>
|
||||
{
|
||||
this.m_Stats.begin();
|
||||
})
|
||||
xaop.end(view, view.Render, () =>
|
||||
{
|
||||
this.m_Stats.end();
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in new issue