2

我想在 Smart Mobile Studio 中添加这个简单的three.js 示例。是否有可能没有大量复杂的包装?我通过将 window.onload 内容复制到 asm 部分来尝试天真的尝试 - 但当然没有运气。

<!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>
4

3 回答 3

3

我生成了一个包装单元(使用我自己的实验性内部打字稿到帕斯卡转换器)并测试了输出(并修复了一些生成器错误): https ://github.com/andremussche/AndrewsDelphiStuff/tree/master/Smart/ThreeJS

仍然不完美(缺少一些外部类名),但无论如何这是一个很好的起点。

在上面的演示中,您还可以看到如何在 SMS IDE 中创建一个纯 html 项目 :)

于 2014-02-26T13:57:40.070 回答
2

我创建了一个演示,它有意尽可能少地偏离 Andre 的示例。更多详细信息,请参见:http ://smartmobilestudio.com/forums/topic/smartms-intro-with-threejs/

于 2014-02-27T12:08:49.450 回答
1

@warleyalex 你的例子对我很有启发。getID 函数正是我所需要的!但可悲的是,它也使短信崩溃。与安德烈的包装解决方案几乎相同。

function getID(OwnerHandle : TObject): string;
begin
  result := TW3TagObj(OwnerHandle).Handle.id;
end;

procedure TForm1.W3ButtonRunClick(Sender: TObject);
var canvas : variant;
begin
  canvas := getID(myCanvas); // myCanvas is a TW3DIVHtmlElement
  asm
    var renderer = new THREE.WebGLRenderer();
    renderer.setSize( 800, 600 );
    var ctnEl = document.getElementById(@canvas);
    ctnEl.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 );             
  end;  
end;
于 2014-02-27T21:33:07.760 回答