mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
[Feature] Improve interacive preview (#15655)
* improve preview * support key f * eslint fix * support reset camera * update code * format code * format code * update code format * remove key down * update code format
This commit is contained in:
@@ -13,7 +13,7 @@ exports.template = /* html */`
|
||||
<div class= "noModel tips">
|
||||
<ui-label class="big" value="i18n:ENGINE.assets.fbx.no_model_tips"></ui-label>
|
||||
<ui-label value="i18n:ENGINE.assets.fbx.drag_model_tips"></ui-label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="preview-container">
|
||||
<div class="animation-info">
|
||||
<div class="flex">
|
||||
@@ -352,7 +352,7 @@ const Elements = {
|
||||
ready() {
|
||||
const panel = this;
|
||||
panel.$.canvas.addEventListener('mousedown', async (event) => {
|
||||
await callModelPreviewFunction('onMouseDown', { x: event.x, y: event.y });
|
||||
await callModelPreviewFunction('onMouseDown', { x: event.x, y: event.y, button: event.button });
|
||||
|
||||
async function mousemove(event) {
|
||||
await callModelPreviewFunction('onMouseMove', {
|
||||
@@ -381,6 +381,14 @@ const Elements = {
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
panel.$.canvas.addEventListener('wheel', async (event) => {
|
||||
await callModelPreviewFunction('onMouseWheel', {
|
||||
wheelDeltaY: event.wheelDeltaY,
|
||||
wheelDeltaX: event.wheelDeltaX,
|
||||
});
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
const GlPreview = Editor._Module.require('PreviewExtends').default;
|
||||
panel.glPreview = new GlPreview('scene:model-preview', 'query-model-preview-data');
|
||||
panel.isPreviewDataDirty = true;
|
||||
@@ -441,8 +449,8 @@ const Elements = {
|
||||
|
||||
exports.methods = {
|
||||
/**
|
||||
*
|
||||
* @param {boolean} hasModel
|
||||
*
|
||||
* @param {boolean} hasModel
|
||||
*/
|
||||
updatePanelHidden(hasModel) {
|
||||
this.$.noModel.hidden = hasModel;
|
||||
|
||||
@@ -95,6 +95,7 @@ exports.methods = {
|
||||
exports.ready = async function() {
|
||||
const panel = this;
|
||||
|
||||
callMaterialPreviewFunction('resetCamera');
|
||||
callMaterialPreviewFunction('setLightEnable', true);
|
||||
panel.$.light.addEventListener('confirm', async () => {
|
||||
await callMaterialPreviewFunction('setLightEnable', this.$.light.checked);
|
||||
@@ -108,7 +109,7 @@ exports.ready = async function() {
|
||||
});
|
||||
|
||||
panel.$.canvas.addEventListener('mousedown', async (event) => {
|
||||
await callMaterialPreviewFunction('onMouseDown', { x: event.x, y: event.y });
|
||||
await callMaterialPreviewFunction('onMouseDown', { x: event.x, y: event.y, button: event.button });
|
||||
|
||||
async function mousemove(event) {
|
||||
await callMaterialPreviewFunction('onMouseMove', {
|
||||
@@ -136,6 +137,14 @@ exports.ready = async function() {
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
panel.$.canvas.addEventListener('wheel', async (event) => {
|
||||
await callMaterialPreviewFunction('onMouseWheel', {
|
||||
wheelDeltaY: event.wheelDeltaY,
|
||||
wheelDeltaX: event.wheelDeltaX
|
||||
});
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
const GlPreview = Editor._Module.require('PreviewExtends').default;
|
||||
panel.glPreview = new GlPreview('scene:material-preview', 'query-material-preview-data');
|
||||
|
||||
@@ -153,6 +162,7 @@ exports.ready = async function() {
|
||||
|
||||
exports.update = async function(assetList, metaList) {
|
||||
const panel = this;
|
||||
callMaterialPreviewFunction('resetCamera');
|
||||
|
||||
panel.assetList = assetList;
|
||||
panel.metaList = metaList;
|
||||
|
||||
@@ -102,7 +102,7 @@ const Elements = {
|
||||
panel.$.canvas.addEventListener('mousedown', async (event) => {
|
||||
// Non-model previews do not respond to events
|
||||
if (panel.$.previewType.value !== previewSelectType.shaded) { return; }
|
||||
await callMeshPreviewFunction('onMouseDown', { x: event.x, y: event.y });
|
||||
await callMeshPreviewFunction('onMouseDown', { x: event.x, y: event.y, button: event.button });
|
||||
|
||||
async function mousemove(event) {
|
||||
await callMeshPreviewFunction('onMouseMove', {
|
||||
@@ -131,6 +131,16 @@ const Elements = {
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
panel.$.canvas.addEventListener('wheel', async (event) => {
|
||||
// Non-model previews do not respond to events
|
||||
if (panel.$.previewType.value !== previewSelectType.shaded) { return; }
|
||||
await callMeshPreviewFunction('onMouseWheel', {
|
||||
wheelDeltaY: event.wheelDeltaY,
|
||||
wheelDeltaX: event.wheelDeltaX,
|
||||
});
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
const GlPreview = Editor._Module.require('PreviewExtends').default;
|
||||
panel.glPreview = new GlPreview('scene:mesh-preview', 'query-mesh-preview-data');
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ const Elements = {
|
||||
const panel = this;
|
||||
|
||||
panel.$.canvas.addEventListener('mousedown', async (event) => {
|
||||
await callSkeletonPreviewFunction('onMouseDown', { x: event.x, y: event.y });
|
||||
await callSkeletonPreviewFunction('onMouseDown', { x: event.x, y: event.y, button: event.button });
|
||||
|
||||
async function mousemove(event) {
|
||||
await callSkeletonPreviewFunction('onMouseMove', {
|
||||
@@ -79,6 +79,15 @@ const Elements = {
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
panel.$.canvas.addEventListener('wheel', async (event) => {
|
||||
await callSkeletonPreviewFunction('onMouseWheel', {
|
||||
wheelDeltaY: event.wheelDeltaY,
|
||||
wheelDeltaX: event.wheelDeltaX,
|
||||
});
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
|
||||
const GlPreview = Editor._Module.require('PreviewExtends').default;
|
||||
panel.glPreview = new GlPreview('scene:skeleton-preview', 'query-skeleton-preview-data');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user