Sign in

    threejs

    js
    js-ffi
    threejs
    Download zip
    Version
    0.0.3
    License
    Apache-2.0
    Last updated
    last year
    Downloads
    51

    #threejs

    Three.js是一个尽可能简化在网页端获取3D内容的库, 这个仓库是在moonbit的移植

    目前还处于开发状态

    #开始

    复制本仓库中的index.html到您的根目录即可, 并对下面的部分进行修改
    <script type="importmap">{ "imports": { "three": "https://threejs.org/build/three.module.js", "game": "替换为您moonbit生成的js文件位置" } } </script>

    #使用

    本项目还未上传至mooncake, 您可以clone本项目然后在本地编译进行测试使用

    IsDirectionalLight

    pub trait IsDirectionalLight : IsObject {
    }

    IsGLTFLoader

    pub trait IsGLTFLoader {
    }

    IsMaterial

    pub trait IsMaterial :
    Cast
    {
    }

    IsObject

    pub trait IsObject :
    Cast
    {
    add(Self,
    Value
    ) -> Unit
    cast_shadow(Self) -> Bool
    id(Self) -> Int
    set_position(Self, Float, Float, Float) -> Unit
    set_rotation(Self, Float, Float, Float, String) -> Unit
    lookat(Self, Float, Float, Float) -> Unit
    }

    IsWebGLRenderer

    pub trait IsWebGLRenderer {
    }

    BufferGeometry

    #external
    pub type BufferGeometry

    Camera

    #external
    pub type Camera

    impl IsObject for Camera

    Camera::new

    fn Camera::new(fov : Float, aspect : Float, near : Float, far : Float) -> Camera

    DRACOLoader

    type DRACOLoader

    DRACOLoader::load

    fn DRACOLoader::load(loader : DRACOLoader, path : String, onload : (GLTF) -> Unit) -> Unit

    DRACOLoader::new

    DRACOLoader::setDecoderPath

    fn DRACOLoader::setDecoderPath(self : DRACOLoader, path : String) -> Unit

    see https://github.com/google/draco/releases https://www.gstatic.com/draco/versioned/decoders/1.5.7/

    DirectionalLight

    type DirectionalLight

    GLTF

    type GLTF

    GLTF::scene

    fn GLTF::scene(self : GLTF) -> Scene

    GLTFLoader

    type GLTFLoader

    GLTFLoader::load

    fn GLTFLoader::load(loader : GLTFLoader, path : String, onload : (GLTF) -> Unit) -> Unit

    GLTFLoader::new

    fn GLTFLoader::new() -> GLTFLoader

    GLTFLoader::setDRACOLoader

    fn GLTFLoader::setDRACOLoader(self : GLTFLoader, dracoLoader : DRACOLoader) -> Unit

    Geometry

    pub(all) struct Geometry {
    bufferGeometry : BufferGeometry
    primitive : Primitive
    }

    Light

    type Light

    Loader

    type Loader

    Material

    type Material

    Mesh

    #external
    pub type Mesh

    impl IsObject for Mesh

    Mesh::new

    fn Mesh::new(geometry : BufferGeometry) -> Object

    MeshPhongMaterial

    type MeshPhongMaterial

    Object

    type Object

    Primitive

    pub(all) enum Primitive {
    BoxGeometry
    CapsuleGeometry
    CircleGeometry
    ConeGeometry
    CylinderGeometry
    DodecahedronGeometry
    EdgesGeometry
    ExtrudeGeometry
    IcosahedronGeometry
    LatheGeometry
    OctahedronGeometry
    ParametricGeometry
    PlaneGeometry
    PolyhedronGeometry
    RingGeometry
    ShapeGeometry
    SphereGeometry
    TetrahedronGeometry
    TorusGeometry
    TorusKnotGeometry
    TubeGeometry
    WireframeGeometry
    }

    Render

    #external
    pub type Render

    Render::newWebGL

    fn Render::newWebGL(canvas : String) -> Render

    Render::render

    fn Render::render(renderer : Render, scene :
    Value
    , camera : Camera) -> Unit

    Render::setPixelRatio

    fn Render::setPixelRatio(renderer : Render, value : Float) -> Unit

    Render::setSize

    fn Render::setSize(renderer : Render, width : Int, height : Int, updateStyle : Bool) -> Unit

    Scene

    #external
    pub type Scene

    impl IsObject for Scene

    Scene::background

    fn Scene::background(self : Scene, color : String) -> Unit

    Scene::new

    fn Scene::new() -> Scene

    add_ffi

    fn add_ffi(parent :
    Value
    , child :
    Value
    ) -> Unit

    cast_shadow_ffi

    fn cast_shadow_ffi(obj :
    Value
    ) -> Bool

    ffi_to_directionalLight

    id_ffi

    fn id_ffi(obj :
    Value
    ) -> Int

    js_identity

    fn[A, B] js_identity(a : A) -> B

    lookat_ffi

    fn lookat_ffi(obj :
    Value
    , x : Float, y : Float, z : Float) -> Unit

    meshBasicMaterial

    fn meshBasicMaterial() -> Material

    newBox

    fn newBox(width : Int, height : Int, depth : Int, widthSegments : Int, heightSegments : Int, depthSegments : Int) -> BufferGeometry

    newCapsule

    fn newCapsule(radius : Float, height : Float, capSegments : Int, radialSegments : Int, heightSegments : Int) -> BufferGeometry

    newCircle

    fn newCircle(radius : Float, segments : Int, thetaStart : Float, thetaLength : Float) -> BufferGeometry

    newCone

    fn newCone(radius : Float, height : Float, radialSegments : Int, heightSegments : Int, openEnded : Bool, thetaStart : Float, thetaLength : Float) -> BufferGeometry

    newCylinder

    fn newCylinder(radiusTop : Float, radiusBottom : Float, height : Float, radialSegments : Int, heightSegments : Int, openEnded : Bool, thetaStart : Float, thetaLength : Float) -> BufferGeometry

    newDodecahedron

    fn newDodecahedron(radius : Float, detail : Int) -> BufferGeometry

    newEdges

    fn newEdges(geometry : BufferGeometry, thresholdAngle : Int) -> BufferGeometry

    newExtrude

    fn newExtrude() -> BufferGeometry

    TODO:

    newIcosahedron

    fn newIcosahedron(radius : Float, detail : Int) -> BufferGeometry

    newLathe

    fn newLathe(segments : Int, phiStart : Float, phiLength : Float) -> BufferGeometry

    TODO:

    newOctahedron

    fn newOctahedron(radius : Float, detail : Int) -> BufferGeometry

    newPlane

    fn newPlane(width : Float, height : Float, widthSegments : Int, heightSegments : Int) -> BufferGeometry

    newPolyhedron

    fn newPolyhedron() -> BufferGeometry

    TODO:

    newRing

    fn newRing(innerRadius : Float, outerRadius : Float, thetaSegments : Int, phiSegments : Int, thetaStart : Float, thetaLength : Float) -> BufferGeometry

    newShape

    fn newShape() -> BufferGeometry

    TODO:

    newSphere

    fn newSphere(radius : Float, widthSegments : Int, heightSegments : Int, phiStart : Float, phiLength : Float, thetaStart : Float, thetaLength : Float) -> BufferGeometry

    newTetrahedron

    fn newTetrahedron(radius : Float, detail : Int) -> BufferGeometry

    newTorus

    fn newTorus(radius : Float, tube : Float, radialSegments : Int, tubularSegments : Int, arc : Float) -> BufferGeometry

    newTorusKnot

    fn newTorusKnot(radius : Float, tube : Float, tubularSegments : Int, radialSegments : Int, p : Int, q : Int) -> BufferGeometry

    newTube

    fn newTube(tubularSegments : Int, radius : Float, radialSegments : Int, closed : Bool) -> BufferGeometry

    TODO:

    newWireframe

    fn newWireframe(geometry : BufferGeometry) -> BufferGeometry

    request_animation_frame

    fn request_animation_frame(f : (Double) -> Unit) -> Double

    https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame

    set_position_ffi

    fn set_position_ffi(obj :
    Value
    , x : Float, y : Float, z : Float) -> Unit

    set_rotation_ffi

    fn set_rotation_ffi(obj :
    Value
    , x : Float, y : Float, z : Float, order : String) -> Unit

    simp_ffi

    fn simp_ffi() -> String