
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<script>
<div id="CanvasBody">
<input id="onDevice" type="button" value="开启陀螺仪">
</div>
<!-- 鼠标控制 (OrbitControlsjs) -->
<script>
THREEOrbitControls=function(object,domElement){return}eventpreventDefault();eventstopPropagation();handleMouseWheel(event);scopedispatchEvent(startEvent);scopedispatchEvent(endEvent)}function onKeyDown(event){if(scopeenabled===false||scopeenableKeys===false||scopeenablePan===false){return}handleKeyDown(event)}function onTouchStart(event){if(scopeenabled===false){return}switch(eventtoucheslength){case 1:if(scopeenableRotate===false){return}handleTouchStartRotate(event);state=STATETOUCH_ROTATE;break;case 2:if(scopeenableZoom===false){return}handleTouchStartDolly(event);state=STATETOUCH_DOLLY;break;case 3:if(scopeenablePan===false)
</script>
<!-- 控制陀螺仪 (DeviceOrientationControlsjs) -->
<!-- 代码 -->
<script>
"use strict";
(function (CanvasBody, _window) {
var Scene = void 0,
Camera = void 0,
Renderer = void 0,
FpsStats = void 0,
AnimateFrame = void 0,
Controls = void 0,
Devices = void 0;
var onDevice = documentgetElementById("onDevice");
var isDeviceing = 0;
/ 初始化函数 /
function initScene() {
Scene = new THREEScene();
}
// 初始化照相机
function initCamera() {
Camera = new THREEPerspectiveCamera(60, CanvasBodyclientWidth / CanvasBodyclientHeight, 1, 3000);
Camerapositionset(1, 0, 0);
CameralookAt({ x: 200, y: 0, z: 0 });
}
// 初始化渲染器
function initRenderer() {
Renderer = new THREEWebGLRenderer();
RenderersetSize(CanvasBodyclientWidth, CanvasBodyclientHeight);
RenderersetClearColor(0x000000, 1);
CanvasBodyappendChild(RendererdomElement);
}
// 初始化监视器
function initFpsStats() {
FpsStats = new Stats();
CanvasBodyappendChild(FpsStatsdomElement);
FpsStatsdomElementstylecssText = "position: absolute;top: 0;left: 0;";
}
// 初始化控制器
function initControls() {
Controls = new THREEOrbitControls(Camera);
}
// 初始化陀螺仪
function initDevices() {
Devices = new THREEDeviceOrientationControls(Camera);
}
/ 窗口改变事件 /
function windowChange() {
initCamera();
RenderersetSize(CanvasBodyclientWidth, CanvasBodyclientHeight);
initDevices();
initControls();
}
/ 控制陀螺仪 /
function controlDevice(event) {
if (isDeviceing === 0) {
isDeviceing = 1;
onDevicevalue = "关闭陀螺仪";
} else {
isDeviceing = 0;
onDevicevalue = "开启陀螺仪";
}
}
/ 动画 /
function animate(time) {
FpsStatsbegin();
Rendererclear();
isDeviceing === 0 Controlsupdate() : Devicesupdate();
Rendererrender(Scene, Camera);
FpsStatsend();
AnimateFrame = requestAnimationFrame(animate);
}
/ 初始化 /
function init() {
// 初始化
initScene();
initCamera();
initRenderer();
initFpsStats();
initControls();
initDevices();
// 初始化绑定陀螺仪
Devicesconnect();
_windowaddEventListener("resize", windowChange, false);
onDeviceaddEventListener("click", controlDevice, false);
AnimateFrame = requestAnimationFrame(animate);
}
init();
/ 场景内物体 /
(function () {
var r = Mathsqrt(5000 1827 / 4 / MathPI);
var texture = THREEImageUtilsloadTexture(">D3 和 Threejs 都是一种用于创建动画的 JavaScript 库,但它们之间有明显的区别。D3 大部分用于提供数据可视化工具,而Threejs 大多用于渲染 3D 图形,并提供用于创建3D 模型的工具。额 这个很简单啊
红包都就没必要了。
你的问题是maya的obj模型 你要转化成threejs的json格式。
threejs提供了这个工具
three/utils/exporters/maya/plug-ins中
是python的
你上github下一份three的源码就好啦就可以用了
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)