GithubHelp home page GithubHelp logo

orillusion / orillusion Goto Github PK

View Code? Open in Web Editor NEW
3.8K 3.8K 437.0 2.7 MB

Orillusion is a pure Web3D rendering engine which is fully developed based on the WebGPU standard.

Home Page: https://www.orillusion.com

License: MIT License

HTML 0.17% JavaScript 0.33% TypeScript 99.47% WGSL 0.03%
3d graphics html5 javascript orillusion typescript web3d webgpu wgsl

orillusion's Introduction

Cover Art

Orillusion

Test npm

Orillusion is a pure Web3D rendering engine which is fully developed based on the WebGPU standard. It aims to achieve desktop-level rendering effects and supports 3D rendering of complex scenes in the browser.

Need to know

Beta version, NOT recommended for any commercial application.

Install

NPM

We recommend using front-end build tools for developing Web3D applications, such Vite or Webpack.

  • Install dependencies:
npm install @orillusion/core --save
  • Import on-demand:
import { Engine3D, Camera3D } from '@orillusion/core'
  • Import globally:
import * as Orillusion from '@orillusion/core'

CDN

In order to use the engine more conveniently, we support to use native <script> tag to import Orillusion. Three different ways to import using the official CDN link:

  • Global Build: You can use Orillusion directly from a CDN via a script tag:
<script src="https://unpkg.com/@orillusion/core/dist/orillusion.umd.js"></script>
<script>  
    const { Engine3D, Camera3D } = Orillusion  
</script>

The above link loads the global build of Orillusion, where all top-level APIs are exposed as properties on the global Orillusion object.

  • ESModule Build: We recommend using the ESModule way for development. As most browsers have supported ES module, we just need to import the ES build version of orillusion.es.js
<script type="module">  
    import { Engine3D, Camera3D } from "https://unpkg.com/@orillusion/core/dist/orillusion.es.js" 
</script>
  • Import Maps: In order to manage the name of dependencies, we recommend using Import Maps
<!-- Define the name or address of ES Module -->  
<script  type="importmap">  
{  
    "imports": { "@orillusion/core": "https://unpkg.com/@orillusion/core/dist/orillusion.es.js" }  
}  
</script>  
<!-- Customerized names could be imported -->  
<script  type="module">  
    import { Engine3D, Camera3D } from "@orillusion/core"
</script>

Usage

Create Engine3D instance

At the beginning, we need to use Engine3D.init() and then the instance Engine3D will be created for further use

import { Engine3D } from '@orillusion/core' 
Engine3D.init().then(()=>{  
    // Next
})

As Engine3D.init() is asynchronous, we recommend using async/await in the code

import { Engine3D } from '@orillusion/core'  
async function demo(){  
    await Engine3D.init();  
    // Next 
}  
demo()

Create canvas

In default, Engine3D.init()will create a canvas the same size with the window. Also, we could create a canvas manually using tag <canvas> with a id

<canvas id="canvas" width="800" height="500" />

Next, we need to get the <canvas> via id and then init engine by passing the <canvas> to canvasConfig

import { Engine3D } from '@orillusion/core';  
let canvas = document.getElementById('canvas')  

await Engine3D.init({  
    canvasConfig: { canvas }  
})

Please read the Docs to Learn More.

Platform

Windows/Mac/Linux:

  • Chrome 113+
  • Edge: 113+

Android (Behind the enable-unsafe-webgpu flag):

  • Chrome Canary 113+
  • Edge Canary 113+

Useful links

Dev and Contribution

Please make sure to read the Contributing Guide before developing or making a pull request.

License

Orillusion engine is released under the MIT license.

orillusion's People

Contributors

codeboy-cn avatar hellmor avatar jiangheng90 avatar jingwenbai avatar lrc199023 avatar lslzl3000 avatar moyuer1992 avatar noah133552 avatar oriiiusion avatar orillusion-admin avatar seven1031 avatar theonlysilverclaw avatar x-oldgentleman avatar zenderjk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orillusion's Issues

[BUG]: point light shadow can't work with dir light shadow

Describe the bug

If there are point/spot lights and dir lights in one scene, only dir light shadow is visible

To Reproduce

Steps to reproduce the behavior:

  1. add a dir light with castShadow, it works fine
  2. then add a point/spot light, can't see its shadow
  3. try to switch the debug option, point shadow only works when there is no dir shadow

Expected behavior

there should be two shadows

Screenshots

on 0.6.2
20230530-122029

on 0.6.3 - 0.6.5, point shadow can't render even with dir light disabled
20230530-131849

Orillusion engine version

0.6.3 - 0.6.5

Code demo link

https://codepen.io/orillusion/pen/jOeQWQP?editors=0010

[BUG]: destroy error with collider on pixel picker

Describe the bug

If destroy an object with ColliderComponent on pixel pick mode, there will be an error on destroy life hook of ColliderComponent.

To Reproduce

Steps to reproduce the behavior:

  1. enable pick and use pixel mode
  2. create an object with simple mesh
  3. add ColliderComponent to the object
  4. call destroy() on the object
  5. the object removed but there is a Uncaught TypeError

Expected behavior

Object3D could destroy with ColliderComponent with picker

Screenshots

Screenshot 2023-05-17 at 10 49 30

Orillusion engine version

0.6.2

Code demo link

https://codepen.io/orillusion/pen/XWxPoWN?editors=1010

[FR]: serialize object for prefab

Is your feature request related to a problem? Please describe

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

A clear and concise description of what you want to happen

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered

Additional context

Add any other context or screenshots about the feature request here

[BUG]: Android Chrome/Edge webgpu error

Describe the bug

Test Orillusion on Android Chrome/Edge 113+, failed to run with webgpu errors

Expected behavior

Should work on Android Chrome, since it also support the same WebGPU APIs

Screenshots

Screenshot 2023-05-20 at 23 12 10

Orillusion engine version

0.6.2

Desktop (please complete the following information)

  • OS: Android
  • Chrome Canary 115
  • Edge Canary 115

[FR]: Provide basic GUI components

Improve engine functionality and provide high-performance 2D rendering components, making it easy for developers to create 2D interfaces.

[BUG]: onCompute function waste of resources

Describe the bug

onCompute function in meshRendererhas some action , but some static mesh not use this function . this is a waste of resources .
you can create a new meshRendererhasto fix this .

Orillusion engine version

State the version you use for developement, e.g. 0.6.0

Desktop (please complete the following information)

  • OS: [e.g. win, mac, android]
  • Browser [e.g. chrome]
  • Version [e.g. 113]

Code demo link

MeshRenderer.ts

protected onCompute(view: View3D, command: GPUCommandEncoder): void {
       if (this.morphData && this.morphData.enable) {
           this.morphData.computeMorphTarget(command);
       }
}

[BUG]: Wrong color value on skybox/background with non-HDR images

Describe the bug

When use LDR/normal images as skybox background, e.g. jpg, png or webp, the rendering color mismatch the pixel color from the source image.

the original rendering by THREE:
Screenshot 2023-05-17 at 17 32 43

the skybox rendering by Orillusion:
Screenshot 2023-05-17 at 17 33 54

Looks like orillusion also add some HDR process on LDR images.

Expected behavior

The skybox could show the original pixel color from LDR images,

Orillusion engine version

0.6.2

Desktop (please complete the following information)

  • OS: mac
  • Browser chrome
  • Version 113 and 115

[BUG]: 在使用自定义canvas时,canvas会自己自动变得很大,无法修改

Bug描述

在使用自定义canvas时,canvas会自己自动变得很大,无法修改

const canvas = document.getElementById('canvas')
await Engine3D.init({
   canvasConfig: { canvas }
})

Bug复现流程

const canvas = document.getElementById('canvas')

期待的结果

简介明要的阐述你期待发生什么结果

报错截图

如果可以,提供发生错误的截图

测试引擎版本:

本地运行出错的Orillusion引擎版本, e.g. 0.6.1

本机系统 (请填写完整):

  • OS: [win]
  • Browser [edge]
  • Version [113.0.1774.42 (正式版本) (64 位)]

代码示例

https://codepen.io/FliPPeDround/pen/mdzzBBJ

其他信息

添加关于bug的其他描述信息

[BUG]: The MeshRenderer is not working after change new material

Describe the bug

The Mesh renderer is not working after change new material

To Reproduce

Steps to reproduce the behavior:

  1. add a box with a LitMaterial
  2. change the box material to a new LitMaterial/UnLitMateral/ImageMaterial/VideoMaterial...
  3. then the box is disappeared/hidden

Expected behavior

A clear and concise description of what you expected to happen

Screenshots

20230529-161301

Orillusion engine version

0.6.3

Desktop (please complete the following information)

  • OS: window, mac
  • Browser chrome canary
  • Version 113 - 116

Code demo link

https://codepen.io/orillusion/pen/xxyNbVQ?editors=0010

[BUG]: 官网demo高光频闪

Bug描述

官网demo高光频闪(类于阳光打在湖面的闪动),高光部分非常不自然,Chome 113在 MAC和Windows下均有同样的表现。

Bug复现流程

通过以下步骤产生bug:

  1. 打开 Chrome 113
  2. 访问 https://www.orillusion.com
  3. 拉到页面到示例位置

期待的结果

高光过渡自然

报错截图

4a7941b534515b29127d0a998a529bc1_0_1683599324.mp4

c6b7c65696c968cf79942aa0b95aeb01_0_1683599134.mp4

视频地址一:https://github.com/Orillusion/orillusion/assets/5469785/b02c581a-eafd-43dc-b4f1-beed62433348
视频地址二:https://github.com/Orillusion/orillusion/assets/5469785/a49abf94-0f4a-4c3b-9e17-a52b2d36670b

测试引擎版本:

本地运行出错的Orillusion引擎版本, e.g. 0.6.1

本机系统 (请填写完整):

  • OS: MacOS
  • Browser: Chrome
  • Version: 113

代码示例

其他信息

Light switch bug

Add a DirectLight and a SpotLight to scene. when DirectLight is disabled, the SpotLight will disabled too。
(DirectLight is red color,SpotLight is blue color。)

all light enable:
image

DirectLight disable, SpotLight is enable
image

engine version 0.5.0

chrome 114.0.5696.0 (Official Build) canary (64-bit)

this is all code:

        Engine3D.setting.shadow.enable = true;

        await Engine3D.init({});

        GUIHelp.init();

        let scene = new Scene3D();

        let cameraObj = new Object3D();
        cameraObj.name = `cameraObj`;
        let mainCamera = cameraObj.addComponent(Camera3D);
        mainCamera.perspective(60, webGPUContext.aspect, 1, 5000.0);

        let hoverCameraController = mainCamera.object3D.addComponent(HoverCameraController);
        scene.addChild(cameraObj);

        //set camera data
        hoverCameraController.setCamera(0, -45, 1000, new Vector3(0, 50, 0));


        {
            let obj = new Object3D();
            obj.localPosition = new Vector3(0, 0, 0);
            obj.localRotation = new Vector3(135, 45, 0);

            let lt: DirectLight = obj.addComponent(DirectLight);
            lt.castShadow = true;
            lt.intensity = 50;
            lt.lightColor = Color.COLOR_RED;
            let mr = obj.addComponent(MeshRenderer);
            mr.castShadow = true;
            mr.geometry = new SphereGeometry(30, 30, 30);
            let mat = new UnLitMaterial();
            mat.baseColor = Color.COLOR_RED;
            mr.material = mat;
            scene.addChild(obj);
            lt.debug();
            GUIHelp.addButton("direct enable switch", () => lt.enable = !lt.enable)
        }

        {
            let obj = new Object3D();
            obj.localPosition = new Vector3(100, 130, 100);
            obj.localRotation = new Vector3(135, 100, 0);

            let lt: SpotLight = obj.addComponent(SpotLight);
            lt.castShadow = true;
            lt.intensity = 100;
            lt.at = 4;
            lt.radius = 10;
            lt.range = 500;
            lt.lightColor = Color.COLOR_BLUE;
            let mr = obj.addComponent(MeshRenderer);
            mr.castShadow = true;
            mr.geometry = new SphereGeometry(30, 30, 30);
            let mat = new UnLitMaterial();
            mat.baseColor = Color.COLOR_BLUE;
            mr.material = mat;
            scene.addChild(obj);
            lt.debug();
            GUIHelp.addButton("spot enable switch", () => lt.enable = !lt.enable)
        }

        // floor
        {
            let mat = new LitMaterial();
            mat.baseMap = defaultTexture.grayTexture;
            let floor = new Object3D();
            let mr = floor.addComponent(MeshRenderer);
            mr.geometry = new BoxGeometry(2000, 1, 2000);
            mr.material = mat;
            scene.addChild(floor);
        }

        let renderJob = new ForwardRenderJob(scene);
        Engine3D.startRender(renderJob);

GTAO

view hemisphere 二重积分计算 screen ao

部分glb文件无法显示

使用 Engine3D.res.loadGltf 来加载 glb 模型,无法加载某些glb文件,问题如下图
image
无法加载的模型文件为https://github.com/mrdoob/three.js/tree/dev/examples/models/gltf 下的Horse.glb
部分模型可以加载
image
2
可以加载的模型为https://github.com/mrdoob/three.js/tree/dev/examples/models/gltf 下的Flower.glb和BoomBox.glb,暂时只尝试了这三个模型,希望能够优化或者在文档中提示一下。

Chrome

版本 113.0.5657.0(正式版本)canary (64 位)

Vite +Vue3

[BUG]: this.textures[e].bindStateChange is not a function

报错信息
TypeError: this.textures[e].bindStateChange is not a function

代码

let scene3D = new Scene3D()
let skyTexture = Engine3D.res.loadLDRTextureCube('/mg.jpg');
let sky = scene3D.addComponent(SkyRenderer)
sky.map = skyTexture;
scene3D.envMap = skyTexture;

我是想试一下自定义全景图天空,按照官网的代码写的,但是报错了

Some feature suggestions for version 0.5

  • Collider
    • Add cylinder preset
  • UI adds some after effects
    • eg: frosted glass, color overlay mode, etc.
    • Text allows gradient colors, shadows, Vertical text, right to right
    • Basic rectangular shape, rounded corners allowed, gradient fill, shadow, stroke, stroke gradient
  • Particle animation
    • more emulators

If the size of the renderer is considered, it can be added in an extended form.

[Topic]: Comparison of WebGPU performance in different operating systems

*All samples run on the same physical device.
*All samples are from WebGPU-samples.
*All systems are native and do not have a virtual machine.
*All sample pages run in fullscreen, using [Command + Shift + F] on macOS and [F11] on Windows.
*All sample FPS statistics are from Chrome's Render Frame status.

Device: MacBook Air (2015)
CPU: Intel Core i5-5250U @1.6GHz
GPU: Intel HD Graphics 6000
RAM: DDR3 4GB

Sample macOS 12.6.5
(Chrome 113.0.5672.92)
Windows 11
(Chrome 113.0.5672.92)
macOS 12.6.5
(Canary 115.0.5773.0)
Windows 11
(Canary 115.0.5773.0)
instancedCube 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
fractalCube 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
cubemap 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
computeBoids 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
animometer
(20k)
42.6 FPS 42.6 FPS 42.0 FPS 42.0 FPS
videoUploading 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
shadowMapping 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
deferredRendering
(256 light)
59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
deferredRendering
(512 light)
51.0 FPS 43.8 FPS 51.0 FPS 45.6 FPS
deferredRendering
(1024 light)
33.6 FPS 28.2 FPS 33.6 FPS 28.8 FPS
particles 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
cornell 54.0 FPS error:
bgra8unorm-storage
not supported
52.8 FPS error:
bgra8unorm-storage
not supported
gameOfLife 59.4 FPS 59.4 FPS 59.4 FPS 59.4 FPS
renderBundles
(5k)
56.4 FPS 59.4 FPS 51.6 FPS 59.4 FPS
renderBundles
(10k)
39.6 FPS 59.4 FPS 38.4 FPS 59.4 FPS

[FR]: 关于大场景的需求。

我在尝试将orillusion用于bim轻量化展示。
bim的建筑模型会保留相当多的内部细节。当前遇到了一些规模很大的bim模型,大概50万个物体,超过数十亿面。
能否有针对大场景绘制的解决方案。
非常感谢。

[FR]: 关于webgpu模拟双精度问题

WebGIS大地坐标系统

在常规的gis引擎中需要双精度来准确的描述地理信息,在webgpu中没有双精度;
在低级别中对精度要求不高的情况:
image
在高级别中对精度要求较高的情况:
image

[BUG]: destroy(true) error if scene has more than one object

Describe the bug

We can call destroy(true) to release all resource of an object.
But if there are multi objects in a scene, call destroy(true) will cause a webgpu error:

Destroyed texture [Texture "default-whiteTexture1616rgba8unorm"] used in a submit.
 - While calling [Queue].Submit([[CommandBuffer]])

To Reproduce

Steps to reproduce the behavior:

  1. add 2 objects in the scene, make sure they don't share geometry and material
  2. try to call destroy(true) on one object
  3. you will see errors in log, and the engine will stop rendering

Expected behavior

if no geometry or material was shared, an object could be destroyed and released

Orillusion engine version

0.6.2

Code demo link

https://codepen.io/orillusion/pen/ZEqMVBp?editors=0010

[FR]: Engine3D destroy and release

The Engine3D could be destroyed and re-create in one window context

  async function demo(){
    //init first Engine3D instance
    await Engine3D.init()
    // ...
    // Destroy it later
    await Engine3D.destroy()
    
    //init a second Engine3D instance
    await Engine3D.init()
    // could destroy it sometime
    await Engine3D.Destroy()
    // ...
  }
  demo()

The Engine3D memory and resources should be released/cleaned after destroy

[FR]: 文档:如何清理资源

当我离开视图(router), 需要清理Orillusion哪些资源?希望文档能补充对这章的明确说明

我目前用到react,react-router-dom,

orillusion demo代码取自于它 https://www.orillusion.com/guide/getting_start/draw_cube.html

我封装了一个orillusion操作类,当离开react router对应的视图时候(组件销毁),调用dispose,发生了如下截图的错误。

import {
  Engine3D,
  Scene3D,
  Object3D,
  Camera3D,
  LitMaterial,
  BoxGeometry,
  MeshRenderer,
  DirectLight,
  HoverCameraController,
  View3D,
  AtmosphericComponent,
} from "@orillusion/core";

export class Tourial {
    canvas: HTMLCanvasElement
    scene: Scene3D|null = null
    view: View3D | null = null
    
  constructor(canvas: HTMLCanvasElement) {
    this.canvas = canvas
    return this;
  }

  async initEngine(){
    await Engine3D.init({
        canvasConfig: { canvas: this.canvas },
      });
  }

  async initView() {
    // create new scene as root node
    const scene3D: Scene3D = new Scene3D();
    this.scene = scene3D;
    // add an Atmospheric sky enviroment
    const sky = scene3D.addComponent(AtmosphericComponent);
    sky.sunY = 0.6;
    // create camera
    const cameraObj: Object3D = new Object3D();
    const camera = cameraObj.addComponent(Camera3D);
    // adjust camera view
    camera.perspective(60, Engine3D.aspect, 1, 5000.0);
    // set camera controller
    const controller = cameraObj.addComponent(HoverCameraController);
    controller.setCamera(0, 0, 15);
    // add camera node
    scene3D.addChild(cameraObj);
    // create light
    const light: Object3D = new Object3D();
    // add direct light component
    const component: DirectLight = light.addComponent(DirectLight);
    // adjust lighting
    light.rotationX = 45;
    light.rotationY = 30;
    component.intensity = 1;
    // add light object
    scene3D.addChild(light);
    // create new object
    const obj: Object3D = new Object3D();
    // add MeshRenderer
    const mr: MeshRenderer = obj.addComponent(MeshRenderer);
    // set geometry
    mr.geometry = new BoxGeometry(5, 5, 5);
    // set material
    mr.material = new LitMaterial();
    // set rotation
    obj.rotationY = 45;
    // add object
    scene3D.addChild(obj);
    // create a view with target scene and camera
    const view = new View3D();
    view.scene = scene3D;
    view.camera = camera;
    // start render
    Engine3D.startRenderView(view);
  }

  dispose(){
    console.log('销毁')
    this.view?.dispose()
    this.scene?.dispose()
  }
}

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.