/egret-3d

Egret3D is a brand new open mobile 3D game and application engine which allows you to quickly build mobile games and apps on Android,iOS and Windows.

Primary LanguageJavaScriptOtherNOASSERTION

issues forks stars license

EN / CN

Egret Engine 3D

Egret is a brand new open mobile 3D game and application engine which allows you to quickly build mobile games and apps on Android,iOS and Windows.

Platforms

Mobile Browsers / WebView Mobile App PC
iOS 7.0+ Android 4.0+ Chrome / FireFox
Android 4.0+ iOS 8.0 + Safari
Windows Phone 8 Windows Phone 8 Edge / IE9+

Show Case

Install

  1. install npm how to install NPM
  2. install typescript
$ npm install typescript -g

install Egret Engine 3D

$ git clone https://github.com/egret-labs/egret-3d.git
$ cd egret-3d
$ cd Egret3D
$ tsc

get JavaScript files

egret-3d/node_modules/egret3d/egret3d.d.ts
egret-3d/node_modules/egret3d/egret3d.js
egret-3d/node_modules/egret3d/egret3d.js.map

Getting Started

Create Project

create a project with Egret Wing

使用Egret Wing创建项目

create a project with Egret Command tool
$ egret create demo

change Main.ts

class Main extends egret.DisplayObjectContainer {

    private _stage3d: egret3d.Stage3D;
    private _view3D: egret3d.View3D;

    public constructor() {
        super();
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.init, this);
    }

    private init() {
        this.removeEventListener(egret.Event.ADDED_TO_STAGE, this.init, this);

        this._stage3d = new egret3d.Stage3D();
        this._stage3d.x = 0;
        this._stage3d.y = 0;
        this._stage3d.width = window.innerWidth;
        this._stage3d.height = window.innerHeight;

        this._view3D = new egret3d.View3D(0, 0, window.innerWidth, window.innerHeight);
        this._view3D.camera3D.lookAt(new egret3d.Vector3D(0, 0, 1000), new egret3d.Vector3D(0, 0, 0));

        this._view3D.backColor = 0xffcccccc;
        this._stage3d.addView3D(this._view3D);
        this._stage3d.start();

        this.createBox();
        this.InitCameraCtl();
        this._stage3d.addEventListener(egret3d.Event3D.ENTER_FRAME, this.update, this);
    }

    private cameraCtl: egret3d.LookAtController;
    private InitCameraCtl() {
        this.cameraCtl = new egret3d.LookAtController(this._view3D.camera3D, new egret3d.Object3D());
        this.cameraCtl.distance = 300;
        this.cameraCtl.rotationX = 0;
    }
    public update(e: egret3d.Event3D) {
        this.cameraCtl.update();
    }

    private createBox() {
        let mat: egret3d.TextureMaterial = new egret3d.TextureMaterial();
        let box: egret3d.CubeGeometry = new egret3d.CubeGeometry(100, 100, 100);
        let mesh: egret3d.Mesh = new egret3d.Mesh(box, mat);
        this._view3D.addChild3D(mesh);
    }
}
Build
$ egret build
Run
$ egret run

if you use Egret Wing, please use F5 with run。

Publish
$ egret publish

Resource

Tools

Document

Social

WeChat

## Contributing

Raising a good question is the first step to participate a open source community.You can report issues [here].

Issue discussion in offical community is recommended. It can help the latters solve problems more efficiently.

License

Copyright (c) 2014-present, Egret Technology. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the Egret nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.