我想在Smart Mobile Studio中添加這個簡單的three.js示例。是否有可能沒有很多複雜的包裝?我試圖通過將window.onload內容複製到一個asm部分嘗試一個天真的嘗試 - 但當然沒有運氣。SmartMan中的「wrap」three.js
<!DOCTYPE html>
<html>
<head>
<title>Getting Started with Three.js</title>
<script src="three.min.js"></script>
<script>
window.onload = function() {
var renderer = new THREE.WebGLRenderer();
renderer.setSize(800, 600);
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
35, // Field of view
800/600, // Aspect ratio
0.1, // Near plane
10000 // Far plane
);
camera.position.set(-15, 10, 10);
camera.lookAt(scene.position);
var geometry = new THREE.CubeGeometry(5, 5, 5);
var material = new THREE.MeshLambertMaterial({ color: 0xFF0000 });
var mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
var light = new THREE.PointLight(0xFFFF00);
light.position.set(10, 0, 10);
scene.add(light);
renderer.render(scene, camera);
};
</script>
</head>
<body></body>
</html>
你試圖避免什麼包裝? – Shiva
包裝不需要非常困難。您可以定義一個Smart Pascal類,並使用「external」指令將其鏈接到相應的JS類。看看Box2d演示。我還沒有看過three.js源代碼,所以我不知道創建封裝器有多容易,但是我知道André(在Smart-team上)正在看這個馬上。也許他會設法爲你創造一個完整的包裝:-) –