-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: 完善部分单测类型,优化帧对比失败提示 * fix: 根据机器人建议优化代码
- Loading branch information
Showing
38 changed files
with
282 additions
and
644 deletions.
There are no files selected for viewing
181 changes: 11 additions & 170 deletions
181
plugin-packages/orientation-transformer/demo/src/simple.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,189 +1,30 @@ | ||
// @ts-nocheck | ||
import { Player } from '@galacean/effects'; | ||
import { getAdapter, type OrientationAdapterAcceler } from '@galacean/effects-plugin-orientation-transformer'; | ||
|
||
const json = { | ||
'compositionId':1, | ||
'requires':[], | ||
'compositions':[ | ||
{ | ||
'name':'composition_1', | ||
'id':1, | ||
'duration':999, | ||
'camera':{ | ||
'fov':30, | ||
'far':20, | ||
'near':0.1, | ||
'position':[ | ||
0, | ||
0, | ||
8, | ||
], | ||
'clipMode':1, | ||
}, | ||
'items':[ | ||
{ | ||
'name':'item_3', | ||
'delay':0, | ||
'id':3, | ||
'type':'2', | ||
'parentId':2, | ||
'ro':0.01, | ||
'particle':{ | ||
'options':{ | ||
'startLifetime':1.2, | ||
'startSize':0.2, | ||
'sizeAspect':1, | ||
'startSpeed':1, | ||
'startColor':[ | ||
'color', | ||
[ | ||
255, | ||
255, | ||
255, | ||
], | ||
], | ||
'duration':2, | ||
'maxCount':10, | ||
'gravityModifier':1, | ||
'renderLevel':'B+', | ||
'looping':true, | ||
}, | ||
'emission':{ | ||
'rateOverTime':5, | ||
}, | ||
'shape':{ | ||
'shape':'Sphere', | ||
'radius':1, | ||
'arc':360, | ||
'arcMode':0, | ||
}, | ||
}, | ||
}, | ||
{ | ||
'name':'plugin_3', | ||
'delay':0, | ||
'id':4, | ||
'type':'5', | ||
'content':{ | ||
'options':{ | ||
'duration':999, | ||
'type':'orientation-transformer', | ||
'renderLevel':'B+', | ||
'targets':[ | ||
{ | ||
'name':'null_1', | ||
'xMin':'3', | ||
'xMax':'-3', | ||
'yMin':'3', | ||
'yMax':'-3', | ||
'vMin': '-20', | ||
'vMax': '20', | ||
'hMin': '-20', | ||
'hMax': '20', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
{ | ||
'name':'null_1', | ||
'delay':0, | ||
'id':2, | ||
'type':'3', | ||
'cal':{ | ||
'options':{ | ||
'duration':2, | ||
'startSize':1, | ||
'sizeAspect':1, | ||
'relative':true, | ||
'renderLevel':'B+', | ||
'looping':true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
'name':'item_1', | ||
'delay':0, | ||
'id':1, | ||
'type':'1', | ||
'parentId':2, | ||
'ro':0.02, | ||
'sprite':{ | ||
'options':{ | ||
'startLifetime':2, | ||
'startSize':1.2, | ||
'sizeAspect':1, | ||
'startColor':[ | ||
'color', | ||
[ | ||
255, | ||
255, | ||
255, | ||
], | ||
], | ||
'duration':2, | ||
'gravityModifier':1, | ||
'renderLevel':'B+', | ||
'looping':true, | ||
}, | ||
'renderer':{ | ||
'renderMode':1, | ||
}, | ||
}, | ||
}, | ||
], | ||
'meta':{ | ||
'previewSize':[ | ||
750, | ||
1334, | ||
], | ||
}, | ||
}, | ||
], | ||
'gltf':[], | ||
'images':[], | ||
'version':'0.9.0', | ||
'shapes':[], | ||
'plugins':[ | ||
'orientation-transformer', | ||
], | ||
'type':'mars', | ||
'_imgs':{ | ||
'1':[], | ||
}, | ||
}; | ||
const json = 'https://mdn.alipayobjects.com/mars/afts/file/A*GbiuQIresOsAAAAAAAAAAAAADlB4AQ'; | ||
const container = document.getElementById('J-container'); | ||
const betaInput = document.querySelector('input[name="beta"]'); | ||
const gammaInput = document.querySelector('input[name="gamma"]'); | ||
const betaInput = document.querySelector('input[name="beta"]') as HTMLInputElement; | ||
const gammaInput = document.querySelector('input[name="gamma"]') as HTMLInputElement; | ||
|
||
(async () => { | ||
const adapter = getAdapter(); | ||
const player = createPlayer(); | ||
const scene = await player.loadScene(json); | ||
const player = new Player({ | ||
container, | ||
pixelRatio: window.devicePixelRatio, | ||
interactive: true, | ||
}); | ||
|
||
betaInput.addEventListener('input', () => { handleInputChange(adapter); }); | ||
gammaInput.addEventListener('input', () => { handleInputChange(adapter); }); | ||
|
||
void player.play(scene); | ||
await player.loadScene(json); | ||
})(); | ||
|
||
function handleInputChange (adapter: OrientationAdapterAcceler) { | ||
adapter.dispatchMotion({ | ||
x: +betaInput.value / 100, | ||
y: +gammaInput.value / 100, | ||
beta: +betaInput.value / 100, | ||
gamma:+gammaInput.value / 100, | ||
}); | ||
document.getElementById('J-info').innerText = `[info] x: ${betaInput.value}, y: ${gammaInput.value}`; | ||
} | ||
|
||
function createPlayer () { | ||
const player = new Player({ | ||
container, | ||
pixelRatio: window.devicePixelRatio, | ||
interactive: true, | ||
gamma: +gammaInput.value / 100, | ||
}); | ||
|
||
return player; | ||
document.getElementById('J-info')!.innerText = `[info] x: ${betaInput.value}, y: ${gammaInput.value}`; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.