Giter Site home page Giter Site logo

galacean / runtime-toolkit Goto Github PK

View Code? Open in Web Editor NEW
65.0 65.0 23.0 1.03 MB

Some out-of-the-box utility features based on the Galacean engine.

Home Page: https://oasisengine.cn

License: MIT License

JavaScript 1.58% TypeScript 91.02% GLSL 0.85% Shell 0.07% C 6.49%
graphics-programming shaders toolkit typescript visual-effects webgl

runtime-toolkit's People

Contributors

cptbtptpbcptdtptp avatar czizzy avatar enhaowu avatar eyworldwide avatar guolei1990 avatar gz65555 avatar hypnosnova avatar jujiex avatar luzhuang avatar singlecoder avatar yangfengzzz avatar zhuxudong 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

Watchers

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

runtime-toolkit's Issues

Gizmo support more precise modification like fix rotation degree and snap

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.

Control extension and customization

很多用户会基于官方的三个控制器(Control)来扩展更高级的业务定制控制器,希望能开放更多的 hook 供使用;比如希望根据当前旋转的角度来动态控制自转的速度(autoRotateSpeed):
image

Control to rotate object

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.

Refactor WireframeManager to LineDrawer

in Editor, the wireframe drawer should move into different editor components, which will call in onSceneGUI, it will be more easy to control the data modification and customization.

Multi Item Selection

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.

Refactor Post-Process selected outline

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 [...]

OrthoControl Optimize Experience

Describe the bug

  1. pan action doesn't follow pointer well
  2. zoom speed need to slow when zoom onto a smaller scale

Expected behavior
Optimize algorithm to enhance experience

Refactor Gizmo to support self-define control

now, Gizmo can control size, translation and rotation. Actually, these three is the basic of viewport manipulation. Gizmo can be refactor to control more paremeter like Collider size, waypoint, and event in CSG modelling mode.

Gizmo should consider to split these three, and make the control target can be self-defined.

Spring Bone

Use spherical joint to build high-level spring bone packages

Infinite grid

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 [...]

Navigation gizmo

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 [...]

RFC: Navigation Gizmo

概要

拼装场景是编辑器的重要功能,除了在透视视角下进行,三视图必不可少。
对于web编辑器来说,除了使用通常的鼠标+键盘的组合控制场景相机,也应该有门槛更低、直观明了的方式控制场景相机,即直接操作可视化场景坐标轴。

功能

  1. 可视化场景轴向
  2. 点击轴点,视图变为相应三视图。比如,点击Y,转到顶视图
  3. 可视化操控场景相机进行旋转

详细设计

形式

参考blender, xyz三轴,轴端为球状轴点。轴点有XYZ节点标识,文字始终大小方向一致。
image

交互

悬浮于区域,区域背景为圆形半透明白色。悬浮于轴点,文字变色。
点击轴点,旋转到对应三视图。
拖拽半透明白色区域,旋转场景相机,并变为透视。

使用

import { NavigationGizmo } from "oasis-engine-toolkit"
const navigationGizmo = rootEntity.addComponent(NavigationGizmo)
// 传入场景相机
navigationGizmo.camera = sceneCamera
// 设置图层,默认为Layer01
navigationGizmo.layer = Layer.Layer10
// 设置位置,默认为右上角(0.8, 0, 0.2, 0.2)
navigationGizmo.viewport(0.8, 0, 0.2, 0.2);

依赖

  "dependencies": {
    "oasis-engine",
    "@oasis-engine/physics-lite",
    "@tweenjs/tween.js",
  }

节点树

image

伪代码

class GizmoScript extends Script {
  constructor() {}
  onUpdate() {
    // 同步 navigationGzimoEntity 和 sceneCameraEntity 的 rotation
  }
}
class SphereScript extends Script {
  constructor() {}
  onPointerEnter() {
    // 出现半透明背景
  }
  onPointerExit() {
    // 消失半透明背景
  }
  onPointerDown() {
    // 变为透视相机
    // 记录初始位置  this.startQuat = ...
    // 获得初始点  this.startPoint = this._getHitPoint()
  }
  onPointerDrag() {
    // 获得转动过程中的点
    this.movePoint = this._getHitPoint();
    // 转过的角度
    const quat = this._getRadian(this.startPoint, this.movePoint);
    // 同步navigationGizmoEntity 的 rotation
  }
  onPointerUp() {
    // 停止转动
  }
  _getHitPoint() {
    // 计算当前点位置
  }
  _getRadian() {
    // 计算空间中两向量夹角
  }
}
class EndScript extends Script {
  constructor() {}
  onPointerEnter() {
    //  文字变色
  }
  onPointerExit() {
    //  文字颜色恢复
  }
  onPointerClick() {
    //  转到相应的视图
  }
  _cameraTween() {
    // 相机转动缓动动画
  }
}

Joystick control

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.

Tumbnail feat

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 [...]

Add arrow wireframe for PlaneColliderShaoe

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.

Infinity grid不显示。

Infinity grid不显示。
复制官方示例,同样不显示grid。

这是我运行的

image

这是官方的示例效果

image

这是我的代码

<template>
	<canvas id="canvas" style="width:500px;height:500px"></canvas>
</template>
<script setup>
import { Camera, WebGLEngine, Vector3 } from "oasis-engine";
import { OrbitControl, GridControl } from "oasis-engine-toolkit";
import {onMounted} from 'vue'
onMounted(() => {
	const engine = new WebGLEngine("canvas");
	engine.canvas.resizeByClientSize();
	engine.sceneManager.activeScene.ambientLight.diffuseSolidColor.set(1,1,1,1);

	const rootEntity = engine.sceneManager.activeScene.createRootEntity();

	const cameraEntity = rootEntity.createChild("camera");
	const camera = cameraEntity.addComponent(Camera);
	cameraEntity.transform.setPosition(6, 6, 6);
	cameraEntity.transform.lookAt(new Vector3());
	cameraEntity.addComponent(OrbitControl);
        
        //无效
	const grid = rootEntity.addComponent(GridControl);
	grid.camera = camera;

	engine.resourceManager
		.load(
			"https://gw.alipayobjects.com/os/OasisHub/267000040/9994/%25E5%25BD%2592%25E6%25A1%25A3.gltf"
		)
		.then((gltf) => {
			rootEntity.addChild(gltf.defaultSceneRoot);
		});

	engine.run();
});
</script>

Just a Test

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.

Snapshot for Differerent Assets

Add a snapshot function to generate HTMLImageElement for preview

function snapshot(asset: Asset, engine: Engine): Promise<HTMLImageElement>;

For Asset, there are serveral types need support:

  • Material
  • Texture
  • Entity
  • Sprite

add tolerance protection in infinity grid when camera is aligned on axis

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.

[Stats] render the stats data without DOM

Is your feature request related to a problem? Please describe.
Stats toolkit can't work in miniprogram because it renders data with DOM API.

Describe the solution you'd like
Maybe we can solve the problem if we use engine's build-in API such as TextRenderer feature.

OrbitControl 点击触发旋转

在react strict模式下使用useEffect的方式初始化引擎及场景,导致orbitControl在pad模式下单点点击便造成rotate

OrbitControl鼠标左键移动没反应

官网的例子原封不动的复制粘贴过来。鼠标左键按住拖拽都没反应。同事苹果电脑没问题。是不兼容window吗?
import { OrbitControl } from "@oasis-engine/controls";
import { Camera, GLTFResource, WebGLEngine } from "oasis-engine";

const engine = new WebGLEngine("canvas");
engine.canvas.resizeByClientSize();

const rootEntity = engine.sceneManager.activeScene.createRootEntity();

const cameraEntity = rootEntity.createChild("camera");
cameraEntity.addComponent(Camera);
cameraEntity.transform.setPosition(3, 3, 3);
cameraEntity.addComponent(OrbitControl);

engine.sceneManager.activeScene.ambientLight.diffuseSolidColor.setValue(1, 1, 1, 1);

engine.resourceManager
.load("https://gw.alipayobjects.com/os/OasisHub/267000040/9994/%25E5%25BD%2592%25E6%25A1%25A3.gltf")
.then((gltf) => {
rootEntity.addChild(gltf.defaultSceneRoot);
});

engine.run();

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.