* TODO 实现基本的数字孪生场景

TODO 支持一个 基本的数字孪生场景：
refer to:
// https://www.hightopo.com/demos/index.html
http://www.mms3d.cn/html/product/slxm/


TODO use echart to draw 2d ui



* 整理需求

切换场景

播放一段相机动画，展示快速漫游

点击模型时，播放模型动画

picking

显示轮廓

线框模式:
绘制线框模式的模型

echart2d图标

3D ui:
text
面板
    面向屏幕
    面向固定方向




场景：
使用免费模型来搭建“园区”场景
大楼+大楼内部
机器+动画



* DONE 搭建场景


场景1:
大楼


场景2:
大楼内部


# 场景：
# 使用免费模型来搭建“园区”场景
# 大楼+大楼内部
# 机器+动画


* TODO 切换场景

# ** TODO add perspective component
** DONE add camera group inspector

include basiccameraview, perspective

TODO add float1 ui control

# ** TODO update basiccameraview component

TODO add checkbox ui control


TODO replace current camera



TODO update:
# ui
# editor-whole
# float1,float3,checkbox ui control i and p
related inputs, actions
checkbox i,p



TODO run test:
editor
run-stop


** DONE fix: if change isActive / far when run,  arcball drag event not work


# ** TODO support not active

# TODO implement not active

# TODO fix: game view handle no active camera when onDispose camera in sceneTree, onDispose basiccameraview, perspective component
#     if no active, not render game view






** DONE add "add Component"
add select button
    ui control
    input
    action


TODO handle duplicate when bundle


run test:
add camera group component
run-stop




** DONE if already has, not add and warn




# ** TODO add "remove Component"

# TODO use button as ui control


# run test:
# remove camera group component


** DONE publish editor


TODO publish:
imgui, ui i,p
# engine-scene
editor-whole
# engine-whole
active action
# float1,float3,checkbox ui control i and p
# related inputs, actions
# checkbox i,p


TODO update package:
ui
editor-whole

** TODO 加入Script

not need attribute?

onInit
    can onInit attributes
onUpdate
# (the first job in render pipeline)
# onDispose
# onStop

# api add scriptAPI:
engineScene add script component:
getGameObject
add/disposeXxx
createAttribute(name, initialValue)
getAttribute(name)
setAttribute(name, value)
getEventFileStr(name)
setEventFileStr(name, fileStr)
# getEventHandle(enum name)


job is in script pipeline


# add script file str
onInit, onUpdate: (api, meta3dState) => Promise<meta3dState>



*** DONE add script component


TODO clone


*** DONE update engine-core service

*** DONE update engineScene service



*** DONE add update script job in gameview pipeline


TODO run test:
default scene's cube add script

*** DONE update run-stop

# TODO update:
# engine-scene
# core

TODO add onStop

TODO exec onInit

TODO exec update in loop


# TODO exec onDispose when stop


TODO run test:


*** TODO add script asset

# TODO use textarea instead of monaco
**** TODO add monaco input ui control
TODO demo
    get pos, size
    show basic editor
    get editor's value
    defer load




TODO add draft


TODO update
imgui p
ui p
codeedit ui control p
# editor-whole




TODO pass run test:
//show codeedit in script inspector
    TODO add fake action to handle submit event
    # TODO verify: defer load

//TODO show add component

//TODO minus width

//TODO show button

//TODO add height to specific data


//TODO fix: initialCode use textarea type
    TODO pass:
    {
        onInit:() =>{
            console.log("aaa")
        }
    }


TODO remove initialCode, add input instead

# switch script inspector and gameobject inspector
dispost script inspector
    TODO code edit ui control: register event when beforeRender:
        hidden container
        # update initialCode

switch
    should update code
        if selected change, set value
            TODO add action-select-node
            TODO update related

            TODO add switch node event

            TODO update all
                fix:
                switch
                dispose
                remove asset
                # clone

# TODO update
# codeedit 
# dispose
# remove



multiple codeedit ui controls
    create self container



**** DONE add asset

# TODO defer load monaco when show script asset

TODO add imagePopup

TODO add select ui control for add script asset

TODO merge load-glb to add-asset

TODO select script, glb asset: show different inspector



# TODO code edit ui control: defer load

TODO update:
# imgui p
# ui p
# editor
# add-asset
# image-popup
# input-asset
# add-glb 
# input-glb-asset-inspector
# input-script-asset-inspector
# set-script-asset-name p
# input-codeedit-script-asset p

# set-script-asset-name p
# meta3d-action-set-script-asset-code p
# meta3d-input-script-asset-name
# meta3d-input-script-asset-codeedit p

# meta3d-ui-control-codeedit
# meta3d-action-set-script-asset-code



add related action,input

replace input-inspector
remove load glb ui
add addasset ui
add glb inspector
add script inspector



TODO pass run test:
add glb
add script
remove glb
remove script
drag glb
select glb
select script
switch script
redo-undo

# export->import





TODO update
# imgui p
# ui p
# codeedit ui control p
# # editor-whole



**** DONE feat: add export/import asset in menu


# TODO add event


TODO remove import-single-event p


TODO update menu





TODO remove   addGLBAsset: (
    Meta3dType.Index.state,
    glb,
    outsideImmutableDataId,
    glbName,
  ) => Meta3dType.Index.state,
  removeGLBAsset: (Meta3dType.Index.state, outsideImmutableDataId) => Meta3dType.Index.state,
  getAllGLBAssets: Meta3dType.Index.state => array<(outsideImmutableDataId, glbName, glb)>,

TODO remove allGLBAssets



# **** TODO feat: rename to export scene in menu; add import scene in menu 
**** DONE feat: rename to export data and rename import event to import in menu



**** TODO init imgui before init action

TODO update meta3d-action-add-asset





TODO update
asset p
editor whole extension
# editor whole

import-data
export-data
add-asset p


TODO pass run test:
export->import
    select asset

export->import->export all events->import all events





# ***** TODO update ui control -> init code

# init get label


**** DONE add script component

TODO restore default scene

TODO updat addcomponent

TODO support add multiple scripts
    # # getAllAssetData
    # getAllAssetNames
    # addAssetData
    # removeAssetData
    # # editAssetData
    # getAssetEventFileStr
    # setAssetEventFileStr
    getAllAssetData
    setAllAssetData


TODO update ScriptAPI



TODO add list demo





TODO add list ui control
    show script component's all script assets

    <selectable+image button>

    specific:
        isRemoveable

    event:
        remove
        select

# TODO add list ui control
# TODO add list ui control

    select script asset by name

    # event:
    #     select

# TODO add text ui control
#     show script namliste


TODO add remove, add, //select actions


TODO add show modal action



# TODO only has one modal
#     add size specific data
#     refactor event



TODO add modal input


TODO add modal select action



# TODO api add scriptAPI to operate attribute


TODO publish all

TODO auto upagrade and publish editor


# TODO test add->close modal

TODO fix url-loader
    not use it!

TODO add ui
    add list
    add add button
    add modal


TODO button specific add isNotAbsolutePosition


//TODO fix(services): meta3d-tool-bundle-to-custom: should only bundle imported variables, remove not imported ones
e.g. A import a1,a2 file
a1,a2 both has export eventName
ut A only need a1's eventName

so bundled one should only has a1's eventName!



TODO fix: remove script asset in script component not work

TODO add: can only add not added ones





TODO run test
add script
remove script
run->invoke scipt
stop->stop script
hot change when run
    handler add param: gameObject
    update script eventfilestr should update script's data
    update script name should update script's name

multiple script assets
redo-undo
        warn: can't add asset to script component when run
    run->add cube->select cube->stop error!

publish to platform:test modal
    show modal






TODO update
# meta3d-action-set-script-asset-name p
# meta3d-action-set-script-asset-code
# meta3d-action-publish-to-platform
# meta3d-action-script-component-add-asset
# meta3d-action-select-inspector-node

# meta3d-action-open-publish-to-platform-modal
# meta3d-action-close-publish-to-platform-modal
# meta3d-action-close-select-script-asset-modal p


# add-asset

# remove-asset

# meta3d-action-script-component-add-asset

# meta3d-action-publish-to-platform

# addcomponent

# list p
# input-list p

# run 
# meta3d-action-add-asset

# gameview render pipeline
# scene render pipeline

# input-addcomponent
# input-script-collapse

# meta3d-input-select-script-asset-names

# imgui
# ui 

# script component p
# engine-scene p

#     ui,gameview package
#     engine-scene package
#     editor-whole package







**** DONE update script default code




**** DONE run-stop

TODO deepCopy scene data when run, restore scene data when stop

TODO how to handle render(e.g. init material shader when run)?
    //dispose all and reinit with retored scene data when stop?
        //only dispose all?
    do nothing!


TODO run test:
change scene data(e.g. transform) when run
    change color
create and init new material shader when run
    dispose cube
        //fix: create script(dispose cube)->add script->run error
create and init new vbo when run



TODO update
run p


# *** TODO pass editor run test




*** DONE fix Enter Final App: not found


*** DONE fix EnterApp

TODO add monaco 

run test:
run editor



TODO refactor: deferLoad duplicate


*** DONE update engine-whole

TODO add onInit, update script job

TODO export should handle script component
    GLTF add script extension
    Mesh.userData add script data?


TODO import should handle script component
    _import read Mesh.userData, then add script component


TODO pass export data run test

TODO pass publish run test
    extract script api: use getEngineSceneService instead of getPackageService



TODO pass publish to platform run test


TODO publish:
# meta3d-export-scene
# engine-core and p;
# gameview pipeline
# sceneview
# webview pipeline
# engine-scene
# imgui p
# ui p
# editor whole

# meta3d-scenegraph-converter-three
# three

# load-glb
# asset

TODO update:
# engine-core
# gameview
# engine-scene
# ui
# editor-whole
# web
# engine-whole







# * TODO perf(editor): solve "memory will increase when run editor"

# # TODO refresh platform
# #     TODO components' arrayBuffer



# TODO run editor will increase

# TODO editor loop will increase


# * TODO perf(editor): optimize editor loading



* DONE fix(platform): create input->set name to exist name->change name to other name: will create dupliate one

* DONE perf(platform): code edit: if change code, not create monaco

# onChange too slow?

if not select action/input, not create react.monaco!
    if select action/input or didMount, dispatch


# * TODO fix: editor: run-stop: should reset arcball in gameview when stop






* DONE publish v1.3.0




* TODO 3D贪吃蛇

# Snake, Scene use gltf model!
Scene use gltf model!


# script:
# control visiable
# bind keyboard event to switch scene


two levels


TODO unbind event when stop

TODO need publish
# run




# ** TODO add 2d ui

** DONE add background scene

** DONE add snake body, can move and change direction by keyboard event
f/b:z
l/r:x

# *** TODO add KeyboardInputAPI to handle keyboard event
# api: input->keyboard, point


# should get and return meta3dState in handler!

# TODO event service add keyboard related api

# TODO add input package to editor-whole package


# TODO commit

*** DONE should unbind event when stop->restore


** DONE fix: export data-> import data: should has script component


** DONE adjust camera

TODO publish all packages
TODO auto upgrade




** DONE add food; snake can eat food;

** DONE switch to second level

** DONE publish


need:
# load-glb
# meta3d-scenegraph-converter-three


* DONE pass publish run test

# TODO add event job



# * TODO publish v1.3.1

# TODO update pro







# * TODO 完善ui control

# ** TODO add arcballCameraController inspector

# TODO add checkbox ui control

# TODO run test:
# editor
# publish


# ** TODO fix: game view handle no active camera when onDispose camera in sceneTree, onDispose basiccameraview, perspective component


# ** TODO add "add Component"
# add select button


# # ** TODO add Modal
# # publish, export should show Modal


# # Menu add "关于Meta3D":
# # show Modal











# # ** TODO add Debug




# # ** TODO Message
# # e.g. show import progress bar



# * TODO 加入Script



# * TODO 3D贪吃蛇

# Snake, Scene use gltf model!




# * TODO engine: add basic 3d UI
# add imgui ui or state ui?


# * TODO 引擎：支持碰撞



# * TODO 实现第一人称漫游场景




