mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
Restructure Module (#7968)
* module restructure * refine * restructure module * merge * revert * fix ci * update import path of unit-test * split 2d and ui * add more module * change audio adapter * rename primitive * config wechat plugin * merge * add category config * merge * merge
This commit is contained in:
+5
-1
@@ -3,7 +3,9 @@
|
||||
"base": { "modules": [ "base" ] },
|
||||
"gfx-webgl": { "modules": [ "gfx-webgl" ] },
|
||||
"gfx-webgl2": { "modules": [ "gfx-webgl2" ] },
|
||||
"ui": { "modules": [ "ui" ] },
|
||||
"3d": { "modules": [ "3d" ]},
|
||||
"2d": { "modules": [ "2d" ]},
|
||||
"ui": { "modules": [ "ui", "2d" ] },
|
||||
"particle": { "modules": [ "particle" ] },
|
||||
"particle-2d": { "modules": [ "particle-2d" ] },
|
||||
"physics-cannon": { "modules": [ "physics-cannon", "physics-framework" ] },
|
||||
@@ -12,6 +14,8 @@
|
||||
"physics-2d-box2d": { "modules": [ "physics-2d-box2d", "physics-2d-framework" ] },
|
||||
"physics-2d-builtin": { "modules": [ "physics-2d-builtin", "physics-2d-framework" ] },
|
||||
"intersection-2d": { "modules": [ "intersection-2d" ] },
|
||||
"primitive": { "modules": [ "primitive" ] },
|
||||
"profiler": { "modules": [ "profiler" ] },
|
||||
"audio": { "modules": [ "audio" ] },
|
||||
"video": { "modules": [ "video" ] },
|
||||
"terrain": { "modules": [ "terrain" ] },
|
||||
|
||||
+3
-3
@@ -29,9 +29,9 @@
|
||||
*/
|
||||
|
||||
import { Color, Vec3 } from '../../../../core/math';
|
||||
import { IAssembler } from '../../../../core/renderer/ui/base';
|
||||
import { MeshRenderData } from '../../../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../../../core/renderer/ui/ui';
|
||||
import { IAssembler } from '../../../renderer/base';
|
||||
import { MeshRenderData } from '../../../renderer/render-data';
|
||||
import { UI } from '../../../renderer/ui';
|
||||
import { Graphics } from '../../../components';
|
||||
import { LineCap, LineJoin, PointFlags } from '../types';
|
||||
import { earcut as Earcut } from './earcut';
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
import { Color, Vec2 } from '../../../../core/math';
|
||||
import { MeshRenderData } from '../../../../core/renderer/ui/render-data';
|
||||
import { MeshRenderData } from '../../../renderer/render-data';
|
||||
import { arc, ellipse, roundRect, tesselateBezier } from '../helper';
|
||||
import { LineCap, LineJoin, PointFlags} from '../types';
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { UIRenderable } from '../../../../core/components/ui-base/ui-renderable';
|
||||
import { IAssemblerManager } from '../../../../core/renderer/ui/base';
|
||||
import { UIRenderable } from '../../../framework/ui-renderable';
|
||||
import { IAssemblerManager } from '../../../renderer/base';
|
||||
import { Graphics } from '../../../components';
|
||||
import { graphicsAssembler as graphics } from './graphics-assembler';
|
||||
export { earcut } from './earcut';
|
||||
@@ -29,8 +29,8 @@
|
||||
*/
|
||||
|
||||
import './utils';
|
||||
|
||||
export * from './graphics';
|
||||
export * from './label';
|
||||
export * from './mask';
|
||||
export * from './sprite';
|
||||
export * from '../../core/renderer/ui/base';
|
||||
@@ -28,12 +28,12 @@
|
||||
* @module ui-assembler
|
||||
*/
|
||||
|
||||
import { SpriteFrame } from '../../../core/assets/sprite-frame';
|
||||
import { SpriteFrame } from '../../assets/sprite-frame';
|
||||
import * as js from '../../../core/utils/js';
|
||||
import { Rect } from '../../../core/math';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Label } from '../../components/label';
|
||||
import { IAssembler } from '../../../core/renderer/ui/base';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { fillMeshVertices3D } from '../utils';
|
||||
import { bmfontUtils } from './bmfontUtils';
|
||||
|
||||
@@ -28,13 +28,12 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { BitmapFont, IConfig, FontLetterDefinition } from '../../../core/assets/bitmap-font';
|
||||
import { SpriteFrame } from '../../../core/assets/sprite-frame';
|
||||
import { isUnicodeCJK, isUnicodeSpace } from '../../../core/utils/text-utils';
|
||||
import { BitmapFont, IConfig, FontLetterDefinition } from '../../assets/bitmap-font';
|
||||
import { SpriteFrame } from '../../assets/sprite-frame';
|
||||
import { isUnicodeCJK, isUnicodeSpace } from '../../utils/text-utils';
|
||||
import { Rect, Size, Vec2 } from '../../../core/math';
|
||||
import { HorizontalTextAlignment, VerticalTextAlignment } from '../../components/label';
|
||||
import { Label, Overflow } from '../../components/label';
|
||||
import { UITransform } from '../../../core/components/ui-base/ui-transform';
|
||||
import { HorizontalTextAlignment, VerticalTextAlignment, Label, Overflow } from '../../components/label';
|
||||
import { UITransform } from '../../framework/ui-transform';
|
||||
import { shareLabelInfo } from './font-utils';
|
||||
|
||||
class LetterInfo {
|
||||
@@ -28,12 +28,12 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { FontAtlas } from '../../../core/assets/bitmap-font';
|
||||
import { FontAtlas } from '../../assets/bitmap-font';
|
||||
import { Color } from '../../../core/math';
|
||||
import { ImageAsset, Texture2D } from '../../../core/assets';
|
||||
import { PixelFormat } from '../../../core/assets/asset-enum';
|
||||
import { BufferTextureCopy } from '../../../core/gfx';
|
||||
import { safeMeasureText, BASELINE_RATIO, MIDDLE_RATIO, getBaselineOffset } from '../../../core/utils';
|
||||
import { safeMeasureText, BASELINE_RATIO, MIDDLE_RATIO, getBaselineOffset } from '../../utils/text-utils';
|
||||
import { director, Director } from '../../../core/director';
|
||||
|
||||
export interface ISharedLabelData {
|
||||
@@ -28,9 +28,9 @@
|
||||
* @module ui-assembler
|
||||
*/
|
||||
|
||||
import { BitmapFont } from '../../../core/assets';
|
||||
import { BitmapFont } from '../../assets';
|
||||
import { Label } from '../../components';
|
||||
import { IAssemblerManager } from '../../../core/renderer/ui/base';
|
||||
import { IAssemblerManager } from '../../renderer/base';
|
||||
import { bmfont } from './bmfont';
|
||||
import { CanvasPool } from './font-utils';
|
||||
import { letter } from './letter';
|
||||
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
import { addon } from '../../../core/utils/js';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Label } from '../../components/label';
|
||||
import { fillMeshVertices3D } from '../utils';
|
||||
import { bmfont } from './bmfont';
|
||||
@@ -30,11 +30,11 @@
|
||||
|
||||
import * as js from '../../../core/utils/js';
|
||||
import { Color, Vec3 } from '../../../core/math';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Label } from '../../components/label';
|
||||
import { IAssembler } from '../../../core/renderer/ui/base';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { ttfUtils } from './ttfUtils';
|
||||
import { IRenderData } from '../../../core/renderer/ui/render-data';
|
||||
import { IRenderData } from '../../renderer/render-data';
|
||||
|
||||
const WHITE = Color.WHITE.clone();
|
||||
|
||||
@@ -28,15 +28,16 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { SpriteFrame, Texture2D } from '../../../core/assets';
|
||||
import { fragmentText, safeMeasureText, getBaselineOffset, BASELINE_RATIO } from '../../../core/utils';
|
||||
import { SpriteFrame } from '../../assets';
|
||||
import { Texture2D } from '../../../core/assets';
|
||||
import { fragmentText, safeMeasureText, getBaselineOffset, BASELINE_RATIO } from '../../utils/text-utils';
|
||||
import { Color, Size, Vec2, Rect } from '../../../core/math';
|
||||
import { HorizontalTextAlignment, Label, LabelOutline, VerticalTextAlignment, LabelShadow } from '../../components';
|
||||
import { ISharedLabelData, LetterRenderTexture } from './font-utils';
|
||||
import { logID } from '../../../core/platform/debug';
|
||||
import { UITransform } from '../../../core/components/ui-base/ui-transform';
|
||||
import { UITransform } from '../../framework/ui-transform';
|
||||
import { legacyCC } from '../../../core/global-exports';
|
||||
import { assetManager } from '../../../core';
|
||||
import { assetManager } from '../../../core/asset-manager';
|
||||
|
||||
const Overflow = Label.Overflow;
|
||||
const MAX_SIZE = 2048;
|
||||
+4
-4
@@ -28,11 +28,11 @@
|
||||
* @module ui-assembler
|
||||
*/
|
||||
|
||||
import { IRenderData, RenderData } from '../../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { IRenderData, RenderData } from '../../renderer/render-data';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Mask, MaskType } from '../../components/mask';
|
||||
import { IAssembler, IAssemblerManager } from '../../../core/renderer/ui/base';
|
||||
import { StencilManager } from '../../../core/renderer/ui/stencil-manager';
|
||||
import { IAssembler, IAssemblerManager } from '../../renderer/base';
|
||||
import { StencilManager } from '../../renderer/stencil-manager';
|
||||
import { simple } from '../sprite';
|
||||
|
||||
const _stencilManager = StencilManager.sharedManager!;
|
||||
@@ -29,10 +29,10 @@
|
||||
*/
|
||||
|
||||
import { Mat4, Vec3 } from '../../../core/math';
|
||||
import { IRenderData, RenderData } from '../../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { IRenderData, RenderData } from '../../renderer/render-data';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Sprite } from '../../components';
|
||||
import { IAssembler } from '../../../core/renderer/ui/base';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { fillVerticesWithoutCalc3D } from '../utils';
|
||||
import { errorID } from '../../../core/platform/debug';
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { UIRenderable } from '../../../core/components/ui-base/ui-renderable';
|
||||
import { IAssemblerManager } from '../../../core/renderer/ui/base';
|
||||
import { UIRenderable } from '../../framework/ui-renderable';
|
||||
import { IAssemblerManager } from '../../renderer/base';
|
||||
import { Sprite } from '../../components';
|
||||
import { barFilled } from './bar-filled';
|
||||
import { radialFilled } from './radial-filled';
|
||||
+4
-4
@@ -28,12 +28,12 @@
|
||||
* @module ui-assembler
|
||||
*/
|
||||
|
||||
import { SpriteFrame } from '../../../core/assets';
|
||||
import { SpriteFrame } from '../../assets';
|
||||
import { Vec2 } from '../../../core/math';
|
||||
import { IRenderData, RenderData } from '../../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { IRenderData, RenderData } from '../../renderer/render-data';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Sprite } from '../../components';
|
||||
import { IAssembler } from '../../../core/renderer/ui/base';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { fillVertices3D } from '../utils';
|
||||
|
||||
const PI_2 = Math.PI * 2;
|
||||
@@ -29,9 +29,9 @@
|
||||
*/
|
||||
|
||||
import { Vec3 } from '../../../core/math';
|
||||
import { IAssembler } from '../../../core/renderer/ui/base';
|
||||
import { IRenderData, RenderData } from '../../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { IRenderData, RenderData } from '../../renderer/render-data';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Sprite } from '../../components';
|
||||
|
||||
const vec3_temps: Vec3[] = [];
|
||||
@@ -28,12 +28,12 @@
|
||||
* @module ui-assembler
|
||||
*/
|
||||
|
||||
import { IUV, SpriteFrame } from '../../../core/assets';
|
||||
import { IUV, SpriteFrame } from '../../assets';
|
||||
import { Color, Mat4, Vec3 } from '../../../core/math';
|
||||
import { IRenderData, RenderData } from '../../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { IRenderData, RenderData } from '../../renderer/render-data';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Sprite } from '../../components';
|
||||
import { IAssembler } from '../../../core/renderer/ui/base';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
|
||||
const vec3_temp = new Vec3();
|
||||
const matrix = new Mat4();
|
||||
@@ -29,11 +29,11 @@
|
||||
*/
|
||||
|
||||
import { Mat4, Vec3, Color } from '../../../core/math';
|
||||
import { RenderData, IRenderData } from '../../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../../core/renderer/ui/ui';
|
||||
import { RenderData, IRenderData } from '../../renderer/render-data';
|
||||
import { UI } from '../../renderer/ui';
|
||||
import { Sprite } from '../../components/sprite';
|
||||
import { UIRenderable } from '../../../core/components/ui-base/ui-renderable';
|
||||
import { IAssembler } from '../../../core/renderer/ui/base';
|
||||
import { UIRenderable } from '../../framework/ui-renderable';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
|
||||
const vec3_temps: Vec3[] = [];
|
||||
for (let i = 0; i < 4; i++) {
|
||||
@@ -29,9 +29,9 @@
|
||||
*/
|
||||
|
||||
import { Color, Mat4, Vec3 } from '../../core/math';
|
||||
import { RenderData } from '../../core/renderer/ui/render-data';
|
||||
import { UI } from '../../core/renderer/ui/ui';
|
||||
import { Node } from '../../core';
|
||||
import { RenderData } from '../renderer/render-data';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { Node } from '../../core/';
|
||||
|
||||
const vec3_temp = new Vec3();
|
||||
const _worldMatrix = new Mat4();
|
||||
@@ -32,9 +32,9 @@
|
||||
import { ccclass, type, serializable, editable } from 'cc.decorator';
|
||||
import { Font } from './font';
|
||||
import { SpriteFrame } from './sprite-frame';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { js } from '../utils';
|
||||
import { warn } from '../platform/debug';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { js } from '../../core/utils';
|
||||
import { warn } from '../../core/platform/debug';
|
||||
|
||||
export interface IConfig {
|
||||
[key: string]: any;
|
||||
@@ -29,9 +29,9 @@
|
||||
* @module asset
|
||||
*/
|
||||
|
||||
import {ccclass} from 'cc.decorator';
|
||||
import { Asset } from './asset';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { ccclass } from 'cc.decorator';
|
||||
import { Asset } from '../../core/assets';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
/**
|
||||
* @en Class for Font handling.
|
||||
@@ -0,0 +1,6 @@
|
||||
export * from './sprite-frame';
|
||||
export { SpriteAtlas } from './sprite-atlas';
|
||||
export { TTFFont } from './ttf-font';
|
||||
export { LabelAtlas } from './label-atlas';
|
||||
export { BitmapFont } from './bitmap-font';
|
||||
export { Font } from './font';
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
import { ccclass } from 'cc.decorator';
|
||||
import { BitmapFont } from './bitmap-font';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
/**
|
||||
* @en Class for LabelAtlas handling.
|
||||
* @zh 艺术数字字体资源类。
|
||||
@@ -31,10 +31,10 @@
|
||||
|
||||
import { EDITOR, TEST } from "internal:constants";
|
||||
import { ccclass, serializable, editable } from 'cc.decorator';
|
||||
import * as js from '../utils/js';
|
||||
import { Asset } from './asset';
|
||||
import * as js from '../../core/utils/js';
|
||||
import { Asset } from '../../core/assets';
|
||||
import { SpriteFrame } from './sprite-frame';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
interface ISpriteAtlasSerializeData{
|
||||
name: string;
|
||||
@@ -32,15 +32,15 @@
|
||||
|
||||
import { ccclass } from 'cc.decorator';
|
||||
import { EDITOR, TEST, BUILD } from 'internal:constants';
|
||||
import { Rect, Size, Vec2 } from '../math';
|
||||
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
|
||||
import { Asset } from './asset';
|
||||
import { RenderTexture } from './render-texture';
|
||||
import { TextureBase } from './texture-base';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { ImageAsset, ImageSource } from './image-asset';
|
||||
import { Texture2D } from './texture-2d';
|
||||
import { errorID } from '../platform/debug';
|
||||
import { Rect, Size, Vec2 } from '../../core/math';
|
||||
import { murmurhash2_32_gc } from '../../core/utils/murmurhash2_gc';
|
||||
import { Asset } from '../../core/assets/asset';
|
||||
import { RenderTexture } from '../../core/assets/render-texture';
|
||||
import { TextureBase } from '../../core/assets/texture-base';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { ImageAsset, ImageSource } from '../../core/assets/image-asset';
|
||||
import { Texture2D } from '../../core/assets/texture-2d';
|
||||
import { errorID } from '../../core/platform/debug';
|
||||
|
||||
const INSET_LEFT = 0;
|
||||
const INSET_TOP = 1;
|
||||
@@ -29,10 +29,10 @@
|
||||
* @module asset
|
||||
*/
|
||||
|
||||
import {ccclass, string, override, serializable} from 'cc.decorator';
|
||||
import { extname } from '../utils/path';
|
||||
import { ccclass, string, override, serializable } from 'cc.decorator';
|
||||
import { extname } from '../../core/utils/path';
|
||||
import { Font } from './font';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
/**
|
||||
* @en Class for TTFFont asset.
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module ui
|
||||
*/
|
||||
import { Mask } from './mask';
|
||||
import { Label } from './label';
|
||||
import { LabelOutline } from './label-outline';
|
||||
import { RichText } from './rich-text';
|
||||
import { Sprite } from './sprite';
|
||||
import { UIMeshRenderer } from './ui-mesh-renderer';
|
||||
import { Graphics } from './graphics';
|
||||
import { UIStaticBatch } from './ui-static-batch';
|
||||
import { UIOpacity } from './ui-opacity';
|
||||
import { js } from '../../core/utils/js';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
|
||||
/**
|
||||
* Alias of [[Mask]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { Mask as MaskComponent };
|
||||
legacyCC.MaskComponent = Mask;
|
||||
js.setClassAlias(Mask, 'cc.MaskComponent');
|
||||
/**
|
||||
* Alias of [[Label]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { Label as LabelComponent };
|
||||
legacyCC.LabelComponent = Label;
|
||||
js.setClassAlias(Label, 'cc.LabelComponent');
|
||||
/**
|
||||
* Alias of [[LabelOutline]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { LabelOutline as LabelOutlineComponent };
|
||||
legacyCC.LabelOutlineComponent = LabelOutline;
|
||||
js.setClassAlias(LabelOutline, 'cc.LabelOutlineComponent');
|
||||
|
||||
/**
|
||||
* Alias of [[RichText]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { RichText as RichTextComponent };
|
||||
legacyCC.RichTextComponent = RichText;
|
||||
js.setClassAlias(RichText, 'cc.RichTextComponent');
|
||||
/**
|
||||
* Alias of [[Sprite]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { Sprite as SpriteComponent };
|
||||
legacyCC.SpriteComponent = Sprite;
|
||||
js.setClassAlias(Sprite, 'cc.SpriteComponent');
|
||||
/**
|
||||
* Alias of [[UIMeshRenderer]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { UIMeshRenderer as UIModelComponent };
|
||||
legacyCC.UIModelComponent = UIMeshRenderer;
|
||||
js.setClassAlias(UIMeshRenderer, 'cc.UIModelComponent');
|
||||
/**
|
||||
* Alias of [[Graphics]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { Graphics as GraphicsComponent };
|
||||
legacyCC.GraphicsComponent = Graphics;
|
||||
js.setClassAlias(Graphics, 'cc.GraphicsComponent');
|
||||
/**
|
||||
* Alias of [[UIStaticBatch]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { UIStaticBatch as UIStaticBatchComponent };
|
||||
js.setClassAlias(UIStaticBatch, 'cc.UIStaticBatchComponent');
|
||||
/**
|
||||
* Alias of [[UIOpacity]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { UIOpacity as UIOpacityComponent };
|
||||
js.setClassAlias(UIOpacity, 'cc.UIOpacityComponent');
|
||||
@@ -30,18 +30,18 @@
|
||||
*/
|
||||
|
||||
import { ccclass, help, executionOrder, menu, tooltip, type, visible, override, editable, serializable } from 'cc.decorator';
|
||||
import { builtinResMgr } from '../../core/3d/builtin';
|
||||
import { InstanceMaterialType, UIRenderable } from '../../core/components/ui-base/ui-renderable';
|
||||
import { builtinResMgr } from '../../core/builtin';
|
||||
import { InstanceMaterialType, UIRenderable } from '../framework/ui-renderable';
|
||||
import { director } from '../../core/director';
|
||||
import { Color } from '../../core/math';
|
||||
import { IMaterialInstanceInfo, scene } from '../../core/renderer';
|
||||
import { IAssembler } from '../../core/renderer/ui/base';
|
||||
import { UI } from '../../core/renderer/ui/ui';
|
||||
import { IAssembler } from '../renderer/base';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { LineCap, LineJoin } from '../assembler/graphics/types';
|
||||
import { Impl } from '../assembler/graphics/webgl/impl';
|
||||
import { RenderingSubMesh } from '../../core';
|
||||
import { RenderingSubMesh } from '../../core/assets';
|
||||
import { Format, PrimitiveMode, Attribute, Device, BufferUsageBit, BufferInfo, MemoryUsageBit } from '../../core/gfx';
|
||||
import { vfmtPosColor, getAttributeStride, getAttributeFormatBytes } from '../../core/renderer/ui/ui-vertex-format';
|
||||
import { vfmtPosColor, getAttributeStride, getAttributeFormatBytes } from '../renderer/ui-vertex-format';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
const _matInsInfo: IMaterialInstanceInfo = {
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
export * from './label';
|
||||
export { Mask } from './mask';
|
||||
export { RichText } from './rich-text';
|
||||
export { Sprite } from './sprite';
|
||||
export { UIMeshRenderer } from './ui-mesh-renderer';
|
||||
export { LabelOutline } from './label-outline';
|
||||
export { Graphics } from './graphics';
|
||||
export { UIStaticBatch } from './ui-static-batch';
|
||||
export { LabelShadow } from './label-shadow';
|
||||
export { UIOpacity } from './ui-opacity';
|
||||
|
||||
export * from './deprecated';
|
||||
@@ -31,10 +31,9 @@
|
||||
|
||||
import { Component } from '../../core/components/component';
|
||||
import { ccclass, help, executionOrder, menu, tooltip, requireComponent, executeInEditMode, serializable } from 'cc.decorator';
|
||||
import { Color } from '../../core/math';
|
||||
import { Color, Vec2 } from '../../core/math';
|
||||
import { Label } from './label';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { Vec2 } from '../../core/math';
|
||||
|
||||
/**
|
||||
* @en Shadow effect for Label component, only for system fonts or TTF fonts
|
||||
@@ -29,13 +29,14 @@
|
||||
* @module ui
|
||||
*/
|
||||
|
||||
import { BitmapFont, Font, ImageAsset, SpriteFrame, Texture2D, Material } from '../../core/assets';
|
||||
import { BitmapFont, Font, SpriteFrame } from '../assets';
|
||||
import { ImageAsset, Texture2D, Material } from '../../core/assets';
|
||||
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, visible, displayName, multiline, type, readOnly, override, serializable, editable } from 'cc.decorator';
|
||||
import { ccenum } from '../../core/value-types/enum';
|
||||
import { UI } from '../../core/renderer/ui/ui';
|
||||
import { FontAtlas } from '../../core/assets/bitmap-font';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { FontAtlas } from '../assets/bitmap-font';
|
||||
import { CanvasPool, ISharedLabelData, LetterRenderTexture } from '../assembler/label/font-utils';
|
||||
import { UIRenderable } from '../../core/components/ui-base/ui-renderable';
|
||||
import { UIRenderable } from '../framework/ui-renderable';
|
||||
import { warnID } from '../../core/platform/debug';
|
||||
import { EDITOR } from 'internal:constants';
|
||||
|
||||
@@ -30,20 +30,21 @@
|
||||
*/
|
||||
|
||||
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, visible, override, serializable, range, slide } from 'cc.decorator';
|
||||
import { InstanceMaterialType, UIRenderable } from '../../core/components/ui-base/ui-renderable';
|
||||
import { InstanceMaterialType, UIRenderable } from '../framework/ui-renderable';
|
||||
import { clamp, Color, Mat4, Vec2, Vec3 } from '../../core/math';
|
||||
import { warnID } from '../../core/platform';
|
||||
import { UI } from '../../core/renderer/ui/ui';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { ccenum } from '../../core/value-types/enum';
|
||||
import { Graphics } from './graphics';
|
||||
import { TransformBit } from '../../core/scene-graph/node-enum';
|
||||
import { Game, SpriteFrame, Material, builtinResMgr, director, RenderingSubMesh } from '../../core';
|
||||
import { SpriteFrame } from '../assets/sprite-frame';
|
||||
import { Game, Material, builtinResMgr, director, RenderingSubMesh } from '../../core/';
|
||||
import { Device, BufferInfo, BufferUsageBit, MemoryUsageBit, PrimitiveMode } from '../../core/gfx';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { MaterialInstance, scene } from '../../core/renderer';
|
||||
import { Model } from '../../core/renderer/scene';
|
||||
import { vfmt, getAttributeStride } from '../../core/renderer/ui/ui-vertex-format';
|
||||
import { Stage } from '../../core/renderer/ui/stencil-manager';
|
||||
import { vfmt, getAttributeStride } from '../renderer/ui-vertex-format';
|
||||
import { Stage } from '../renderer/stencil-manager';
|
||||
|
||||
const _worldMatrix = new Mat4();
|
||||
const _vec2_temp = new Vec2();
|
||||
@@ -29,20 +29,21 @@
|
||||
* @module ui
|
||||
*/
|
||||
|
||||
import { Font, SpriteAtlas, SpriteFrame, TTFFont } from '../../core/assets';
|
||||
import { Font, SpriteAtlas, TTFFont, SpriteFrame } from '../assets';
|
||||
import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, multiline, type, serializable } from 'cc.decorator';
|
||||
import { assert, EventTouch, warnID } from '../../core/platform';
|
||||
import { BASELINE_RATIO, fragmentText, HtmlTextParser, IHtmlTextParserResultObj, IHtmlTextParserStack, isUnicodeCJK, isUnicodeSpace } from '../../core/utils';
|
||||
import { BASELINE_RATIO, fragmentText, isUnicodeCJK, isUnicodeSpace } from '../utils/text-utils';
|
||||
import { HtmlTextParser, IHtmlTextParserResultObj, IHtmlTextParserStack } from '../utils/html-text-parser';
|
||||
import Pool from '../../core/utils/pool';
|
||||
import { Color, Vec2 } from '../../core/math';
|
||||
import { Node, PrivateNode } from '../../core/scene-graph';
|
||||
import { CacheMode, HorizontalTextAlignment, Label, VerticalTextAlignment } from './label';
|
||||
import { LabelOutline } from './label-outline';
|
||||
import { Sprite } from './sprite';
|
||||
import { UIComponent, UIRenderable, UITransform } from '../../core/components/ui-base';
|
||||
import { UIComponent, UIRenderable, UITransform } from '../framework';
|
||||
import { DEV, EDITOR } from 'internal:constants';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { Component } from "../../core/components";
|
||||
import { Component } from '../../core/components';
|
||||
import assetManager from '../../core/asset-manager/asset-manager';
|
||||
|
||||
const _htmlTextParser = new HtmlTextParser();
|
||||
@@ -29,15 +29,15 @@
|
||||
* @module ui
|
||||
*/
|
||||
|
||||
import { SpriteAtlas } from '../../core/assets/sprite-atlas';
|
||||
import { SpriteFrame } from '../../core/assets/sprite-frame';
|
||||
import { SpriteAtlas } from '../assets/sprite-atlas';
|
||||
import { SpriteFrame } from '../assets/sprite-frame';
|
||||
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, range, editable, serializable } from 'cc.decorator';
|
||||
import { SystemEventType } from '../../core/platform/event-manager/event-enum';
|
||||
import { Vec2 } from '../../core/math';
|
||||
import { ccenum } from '../../core/value-types/enum';
|
||||
import { clamp } from '../../core/math/utils';
|
||||
import { UI } from '../../core/renderer/ui/ui';
|
||||
import { UIRenderable, InstanceMaterialType } from '../../core/components/ui-base/ui-renderable';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { UIRenderable, InstanceMaterialType } from '../framework/ui-renderable';
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { PixelFormat } from '../../core/assets/asset-enum';
|
||||
@@ -29,12 +29,12 @@
|
||||
* @module ui
|
||||
*/
|
||||
|
||||
import { RenderableComponent } from '../../core/3d/framework/renderable-component';
|
||||
import { UIComponent } from '../../core/components/ui-base/ui-component';
|
||||
import { RenderableComponent } from '../../core/components/renderable-component';
|
||||
import { UIComponent } from '../framework/ui-component';
|
||||
import { ccclass, help, executionOrder, menu } from 'cc.decorator';
|
||||
import { director } from '../../core/director';
|
||||
import { RenderPriority } from '../../core/pipeline/define';
|
||||
import { UI } from '../../core/renderer/ui/ui';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { scene } from '../../core/renderer';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
*/
|
||||
|
||||
import { ccclass, help, menu, executionOrder, visible, override } from 'cc.decorator';
|
||||
import { UIRenderable } from '../../core/components/ui-base/ui-renderable';
|
||||
import { UI } from '../../core/renderer/ui/ui';
|
||||
import { MeshBuffer } from '../../core/renderer/ui/mesh-buffer';
|
||||
import { UIDrawBatch } from '../../core/renderer/ui/ui-draw-batch';
|
||||
import { UIRenderable } from '../framework/ui-renderable';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { MeshBuffer } from '../renderer/mesh-buffer';
|
||||
import { UIDrawBatch } from '../renderer/ui-draw-batch';
|
||||
import { director, Color, warnID } from '../../core';
|
||||
import { vfmtPosUvColor } from '../../core/renderer/ui/ui-vertex-format';
|
||||
import { vfmtPosUvColor } from '../renderer/ui-vertex-format';
|
||||
import { BlendFactor } from '../../core/gfx';
|
||||
|
||||
/**
|
||||
@@ -32,21 +32,21 @@
|
||||
import { ccclass, help, disallowMultiple, executeInEditMode,
|
||||
executionOrder, menu, requireComponent, tooltip, type, serializable } from 'cc.decorator';
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { Camera } from '../../3d/framework/camera-component';
|
||||
import { Widget } from '../../../ui/components/widget';
|
||||
import { RenderTexture } from '../../assets/render-texture';
|
||||
import { game } from '../../game';
|
||||
import { ClearFlag } from '../../gfx/define';
|
||||
import { Color, Vec3, Rect, Size } from '../../math';
|
||||
import { view } from '../../platform/view';
|
||||
import visibleRect from '../../platform/visible-rect';
|
||||
import { Node } from '../../scene-graph/node';
|
||||
import { Enum } from '../../value-types';
|
||||
import { Component } from '../component';
|
||||
import { Camera } from '../../core/components/camera-component';
|
||||
import { Widget } from '../../ui/widget';
|
||||
import { RenderTexture } from '../../core/assets/render-texture';
|
||||
import { game } from '../../core/game';
|
||||
import { ClearFlag } from '../../core/gfx/define';
|
||||
import { Color, Vec3, Rect, Size } from '../../core/math';
|
||||
import { view } from '../../core/platform/view';
|
||||
import visibleRect from '../../core/platform/visible-rect';
|
||||
import { Node } from '../../core/scene-graph/node';
|
||||
import { Enum } from '../../core/value-types';
|
||||
import { Component } from '../../core/components/component';
|
||||
import { UITransform } from './ui-transform';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
import { RenderWindow } from '../../renderer/core/render-window';
|
||||
import { SystemEventType } from '../../platform/event-manager';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { RenderWindow } from '../../core/renderer/core/render-window';
|
||||
import { SystemEventType } from '../../core/platform/event-manager';
|
||||
|
||||
const _worldPos = new Vec3();
|
||||
|
||||
@@ -291,7 +291,7 @@ export class Canvas extends Component {
|
||||
|
||||
public __preload () {
|
||||
// Stretch to matched size during the scene initialization
|
||||
const widget = this.getComponent(Widget);
|
||||
const widget = this.getComponent('cc.Widget') as unknown as Widget;
|
||||
if (widget) {
|
||||
widget.updateAlignment();
|
||||
} else if (EDITOR) {
|
||||
@@ -23,47 +23,47 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module ui
|
||||
*/
|
||||
|
||||
import { removeProperty } from '../../utils';
|
||||
import { UIComponent } from './ui-component';
|
||||
import { UITransform } from './ui-transform';
|
||||
import { UIRenderable } from './ui-renderable';
|
||||
import { Canvas } from './canvas';
|
||||
import { js } from '../../utils/js';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
|
||||
removeProperty(UIComponent.prototype, 'UIComponent',[
|
||||
{
|
||||
name: '_visibility',
|
||||
},
|
||||
{
|
||||
name: 'setVisibility',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Alias of [[UITransform]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { UITransform as UITransformComponent };
|
||||
legacyCC.UITransformComponent = UITransform;
|
||||
js.setClassAlias(UITransform, 'cc.UITransformComponent');
|
||||
|
||||
/**
|
||||
* Alias of [[UIRenderable]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { UIRenderable as RenderComponent };
|
||||
js.setClassAlias(UIRenderable, 'cc.RenderComponent');
|
||||
|
||||
/**
|
||||
* Alias of [[Canvas]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { Canvas as CanvasComponent };
|
||||
legacyCC.CanvasComponent = Canvas;
|
||||
js.setClassAlias(Canvas, 'cc.CanvasComponent');
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module ui
|
||||
*/
|
||||
|
||||
import { removeProperty } from '../../core/utils';
|
||||
import { UIComponent } from './ui-component';
|
||||
import { UITransform } from './ui-transform';
|
||||
import { UIRenderable } from './ui-renderable';
|
||||
import { Canvas } from './canvas';
|
||||
import { js } from '../../core/utils/js';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
removeProperty(UIComponent.prototype, 'UIComponent',[
|
||||
{
|
||||
name: '_visibility',
|
||||
},
|
||||
{
|
||||
name: 'setVisibility',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Alias of [[UITransform]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { UITransform as UITransformComponent };
|
||||
legacyCC.UITransformComponent = UITransform;
|
||||
js.setClassAlias(UITransform, 'cc.UITransformComponent');
|
||||
|
||||
/**
|
||||
* Alias of [[UIRenderable]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { UIRenderable as RenderComponent };
|
||||
js.setClassAlias(UIRenderable, 'cc.RenderComponent');
|
||||
|
||||
/**
|
||||
* Alias of [[Canvas]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { Canvas as CanvasComponent };
|
||||
legacyCC.CanvasComponent = Canvas;
|
||||
js.setClassAlias(Canvas, 'cc.CanvasComponent');
|
||||
@@ -29,10 +29,10 @@
|
||||
*/
|
||||
|
||||
import { ccclass, disallowMultiple, executeInEditMode, executionOrder, requireComponent } from 'cc.decorator';
|
||||
import { UI } from '../../renderer/ui/ui';
|
||||
import { Component } from '../component';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { Component } from '../../core/components/component';
|
||||
import { UITransform } from './ui-transform';
|
||||
import { Node } from '../../scene-graph';
|
||||
import { Node } from '../../core/scene-graph';
|
||||
|
||||
/**
|
||||
* @en Legacy UI base class for rendering component, please use [[UIRenderable]] instead.
|
||||
+16
-16
@@ -29,24 +29,24 @@
|
||||
*/
|
||||
|
||||
import { ccclass, executeInEditMode, requireComponent, disallowMultiple, tooltip, type, displayOrder, serializable, override, visible, displayName } from 'cc.decorator';
|
||||
import { Color } from '../../math';
|
||||
import { SystemEventType } from '../../platform/event-manager/event-enum';
|
||||
import { ccenum } from '../../value-types/enum';
|
||||
import { builtinResMgr } from '../../3d/builtin/init';
|
||||
import { Material } from '../../assets';
|
||||
import { BlendFactor } from '../../gfx/define';
|
||||
import { IMaterialInstanceInfo } from '../../renderer/core/material-instance';
|
||||
import { IAssembler, IAssemblerManager } from '../../renderer/ui/base';
|
||||
import { RenderData } from '../../renderer/ui/render-data';
|
||||
import { UI } from '../../renderer/ui/ui';
|
||||
import { Node } from '../../scene-graph';
|
||||
import { TransformBit } from '../../scene-graph/node-enum';
|
||||
import { Color } from '../../core/math';
|
||||
import { SystemEventType } from '../../core/platform/event-manager/event-enum';
|
||||
import { ccenum } from '../../core/value-types/enum';
|
||||
import { builtinResMgr } from '../../core/builtin';
|
||||
import { Material } from '../../core/assets';
|
||||
import { BlendFactor } from '../../core/gfx/define';
|
||||
import { IMaterialInstanceInfo } from '../../core/renderer/core/material-instance';
|
||||
import { IAssembler, IAssemblerManager } from '../renderer/base';
|
||||
import { RenderData } from '../renderer/render-data';
|
||||
import { UI } from '../renderer/ui';
|
||||
import { Node } from '../../core/scene-graph';
|
||||
import { TransformBit } from '../../core/scene-graph/node-enum';
|
||||
import { UITransform } from './ui-transform';
|
||||
import { RenderableComponent } from '../../3d/framework/renderable-component';
|
||||
import { RenderableComponent } from '../../core/components/renderable-component';
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { Stage } from '../../renderer/ui/stencil-manager';
|
||||
import { warnID } from '../../platform/debug';
|
||||
import { murmurhash2_32_gc } from '../../utils';
|
||||
import { Stage } from '../renderer/stencil-manager';
|
||||
import { warnID } from '../../core/platform/debug';
|
||||
import { murmurhash2_32_gc } from '../../core/utils';
|
||||
|
||||
// hack
|
||||
ccenum(BlendFactor);
|
||||
@@ -30,15 +30,15 @@
|
||||
|
||||
import { ccclass, help, executeInEditMode, executionOrder, menu, tooltip, displayOrder, serializable, disallowMultiple } from 'cc.decorator';
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { Component } from '../component';
|
||||
import { SystemEventType } from '../../platform/event-manager/event-enum';
|
||||
import { EventListener, IListenerMask } from '../../platform/event-manager/event-listener';
|
||||
import { Mat4, Rect, Size, Vec2, Vec3 } from '../../math';
|
||||
import { AABB } from '../../geometry';
|
||||
import { Component } from '../../core/components';
|
||||
import { SystemEventType } from '../../core/platform/event-manager/event-enum';
|
||||
import { EventListener, IListenerMask } from '../../core/platform/event-manager/event-listener';
|
||||
import { Mat4, Rect, Size, Vec2, Vec3 } from '../../core/math';
|
||||
import { AABB } from '../../core/geometry';
|
||||
import { Canvas } from './canvas';
|
||||
import { Node } from '../../scene-graph';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
import { warnID } from '../../platform/debug';
|
||||
import { Node } from '../../core/scene-graph';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { warnID } from '../../core/platform/debug';
|
||||
|
||||
const _vec2a = new Vec2();
|
||||
const _vec2b = new Vec2();
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import {
|
||||
barFilled,
|
||||
bmfont,
|
||||
CanvasPool,
|
||||
graphics,
|
||||
graphicsAssembler,
|
||||
labelAssembler,
|
||||
letter,
|
||||
mask,
|
||||
maskEnd,
|
||||
radialFilled,
|
||||
simple,
|
||||
sliced,
|
||||
spriteAssembler,
|
||||
ttf,
|
||||
earcut,
|
||||
} from './assembler';
|
||||
import { MeshBuffer } from './renderer/mesh-buffer';
|
||||
import * as UIVertexFormat from './renderer/ui-vertex-format';
|
||||
import { StencilManager } from './renderer/stencil-manager';
|
||||
import { legacyCC } from '../core/global-exports';
|
||||
|
||||
import './renderer/ui';
|
||||
|
||||
export * from './assets';
|
||||
export * from './framework';
|
||||
export * from './components';
|
||||
export * from './renderer/base';
|
||||
export * from './utils';
|
||||
|
||||
export {
|
||||
MeshBuffer,
|
||||
UIVertexFormat,
|
||||
StencilManager,
|
||||
CanvasPool,
|
||||
// barFilled,
|
||||
// radialFilled,
|
||||
// simple,
|
||||
// sliced,
|
||||
// ttf,
|
||||
// bmfont,
|
||||
// letter,
|
||||
// mask,
|
||||
// maskEnd,
|
||||
spriteAssembler,
|
||||
// graphics,
|
||||
labelAssembler,
|
||||
graphicsAssembler,
|
||||
earcut,
|
||||
};
|
||||
|
||||
legacyCC.UI = {
|
||||
MeshBuffer,
|
||||
UIVertexFormat,
|
||||
// barFilled,
|
||||
// radialFilled,
|
||||
// simple,
|
||||
// sliced,
|
||||
// ttf,
|
||||
// bmfont,
|
||||
// letter,
|
||||
// mask,
|
||||
// maskEnd,
|
||||
// graphics,
|
||||
spriteAssembler,
|
||||
graphicsAssembler,
|
||||
labelAssembler,
|
||||
};
|
||||
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import { UIRenderable } from '../../components/ui-base/ui-renderable';
|
||||
import { UIRenderable } from '../framework/ui-renderable';
|
||||
|
||||
export interface IAssembler {
|
||||
[key: string]: any;
|
||||
@@ -27,10 +27,10 @@
|
||||
* @packageDocumentation
|
||||
* @module ui
|
||||
*/
|
||||
import { BufferUsageBit, MemoryUsageBit } from '../../gfx/define';
|
||||
import { InputAssemblerInfo, Attribute, Buffer, BufferInfo } from '../../gfx';
|
||||
import { BufferUsageBit, MemoryUsageBit } from '../../core/gfx/define';
|
||||
import { InputAssemblerInfo, Attribute, Buffer, BufferInfo } from '../../core/gfx';
|
||||
import { UI } from './ui';
|
||||
import { InputAssemblerHandle, NULL_HANDLE, IAPool } from '../core/memory-pools';
|
||||
import { InputAssemblerHandle, NULL_HANDLE, IAPool } from '../../core/renderer/core/memory-pools';
|
||||
import { getAttributeFormatBytes } from './ui-vertex-format';
|
||||
|
||||
export class MeshBuffer {
|
||||
@@ -28,9 +28,9 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { Material } from '../../assets/material';
|
||||
import { Color } from '../../math';
|
||||
import { Pool, RecyclePool } from '../../memop';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { Color } from '../../core/math';
|
||||
import { Pool, RecyclePool } from '../../core/memop';
|
||||
|
||||
export interface IRenderData {
|
||||
x: number;
|
||||
@@ -27,10 +27,10 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { UIRenderable } from '../../../../exports/ui';
|
||||
import { Material } from '../../assets/material';
|
||||
import { ComparisonFunc, StencilOp } from '../../gfx/define';
|
||||
import { Pass } from '../core/pass';
|
||||
import { UIRenderable } from '../framework';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { ComparisonFunc, StencilOp } from '../../core/gfx/define';
|
||||
import { Pass } from '../../core/renderer/core/pass';
|
||||
|
||||
// Stage types
|
||||
export enum Stage {
|
||||
@@ -28,15 +28,15 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { MeshBuffer } from '../../../ui';
|
||||
import { Material } from '../../assets/material';
|
||||
import { Texture, Sampler } from '../../gfx';
|
||||
import { Node } from '../../scene-graph';
|
||||
import { Camera } from '../scene/camera';
|
||||
import { Model } from '../scene/model';
|
||||
import { MeshBuffer } from './mesh-buffer';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { Texture, Sampler } from '../../core/gfx';
|
||||
import { Node } from '../../core/scene-graph';
|
||||
import { Camera } from '../../core/renderer/scene/camera';
|
||||
import { Model } from '../../core/renderer/scene/model';
|
||||
import { UI } from './ui';
|
||||
import { InputAssemblerHandle, DescriptorSetHandle, NULL_HANDLE, UIBatchHandle, UIBatchPool, UIBatchView, DSPool } from '../core/memory-pools';
|
||||
import { Layers } from '../../scene-graph/layers';
|
||||
import { InputAssemblerHandle, DescriptorSetHandle, NULL_HANDLE, UIBatchHandle, UIBatchPool, UIBatchView, DSPool } from '../../core/renderer/core/memory-pools';
|
||||
import { Layers } from '../../core/scene-graph/layers';
|
||||
|
||||
const UI_VIS_FLAG = Layers.Enum.NONE | Layers.Enum.UI_3D;
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { Material } from '../../assets/material';
|
||||
import { Pass } from '../../renderer/core/pass';
|
||||
import { PassView, PassPool, DescriptorSetHandle, NULL_HANDLE } from '../core/memory-pools';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { Pass } from '../../core/renderer/core/pass';
|
||||
import { PassView, PassPool, DescriptorSetHandle, NULL_HANDLE } from '../../core/renderer/core/memory-pools';
|
||||
|
||||
export interface IUIMaterialInfo {
|
||||
material: Material;
|
||||
@@ -28,9 +28,9 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { AttributeName, Format, FormatInfos } from '../../gfx/define';
|
||||
import { Attribute } from '../../gfx';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
import { AttributeName, Format, FormatInfos } from '../../core/gfx/define';
|
||||
import { Attribute } from '../../core/gfx';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
export const vfmt = [
|
||||
new Attribute(AttributeName.ATTR_POSITION, Format.RGB32F),
|
||||
@@ -27,29 +27,30 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { UIStaticBatch } from '../../../ui';
|
||||
import { Material } from '../../assets/material';
|
||||
import { Canvas, UIComponent, UIRenderable } from '../../components/ui-base';
|
||||
import { Texture, Device, Attribute, Sampler, DescriptorSetInfo } from '../../gfx';
|
||||
import { Pool, RecyclePool } from '../../memop';
|
||||
import { CachedArray } from '../../memop/cached-array';
|
||||
import { Camera } from '../scene/camera';
|
||||
import { Model } from '../scene/model';
|
||||
import { RenderScene } from '../scene/render-scene';
|
||||
import { Root } from '../../root';
|
||||
import { Layers, Node } from '../../scene-graph';
|
||||
import { UIStaticBatch } from '../components';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { Canvas, UIComponent, UIRenderable } from '../framework';
|
||||
import { Texture, Device, Attribute, Sampler, DescriptorSetInfo } from '../../core/gfx';
|
||||
import { Pool, RecyclePool } from '../../core/memop';
|
||||
import { CachedArray } from '../../core/memop/cached-array';
|
||||
import { Camera } from '../../core/renderer/scene/camera';
|
||||
import { Model } from '../../core/renderer/scene/model';
|
||||
import { RenderScene } from '../../core/renderer/scene/render-scene';
|
||||
import { Root } from '../../core/root';
|
||||
import { Layers, Node } from '../../core/scene-graph';
|
||||
import { MeshBuffer } from './mesh-buffer';
|
||||
import { StencilManager } from './stencil-manager';
|
||||
import { UIDrawBatch } from './ui-draw-batch';
|
||||
import { UIMaterial } from './ui-material';
|
||||
import * as UIVertexFormat from './ui-vertex-format';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
import { DescriptorSetHandle, DSPool, SubModelPool, SubModelView } from '../core/memory-pools';
|
||||
import { ModelLocalBindings } from '../../pipeline/define';
|
||||
import { EffectAsset, RenderTexture, SpriteFrame } from '../../assets';
|
||||
import { programLib } from '../core/program-lib';
|
||||
import { TextureBase } from '../../assets/texture-base';
|
||||
import { sys } from '../../platform/sys';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { DescriptorSetHandle, DSPool, SubModelPool, SubModelView } from '../../core/renderer/core/memory-pools';
|
||||
import { ModelLocalBindings } from '../../core/pipeline/define';
|
||||
import { EffectAsset, RenderTexture } from '../../core/assets';
|
||||
import { SpriteFrame } from '../assets';
|
||||
import { programLib } from '../../core/renderer/core/program-lib';
|
||||
import { TextureBase } from '../../core/assets/texture-base';
|
||||
import { sys } from '../../core/platform/sys';
|
||||
|
||||
const _dsInfo = new DescriptorSetInfo(null!);
|
||||
|
||||
@@ -788,3 +789,5 @@ export class UI {
|
||||
this._descriptorSetCacheMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
legacyCC.internal.UI = UI;
|
||||
@@ -28,9 +28,12 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { warnID } from '../platform/debug';
|
||||
import { safeMeasureText } from '../utils/text-utils';
|
||||
import { CompleteCallback, IDownloadParseOptions } from './shared';
|
||||
import { warnID } from '../../core/platform/debug';
|
||||
import { safeMeasureText } from './text-utils';
|
||||
import { CompleteCallback, IDownloadParseOptions } from '../../core/asset-manager/shared';
|
||||
import downloader from '../../core/asset-manager/downloader';
|
||||
import factory from '../../core/asset-manager/factory';
|
||||
import { TTFFont } from '../assets/ttf-font';
|
||||
|
||||
interface IFontLoadHandle {
|
||||
fontFamilyName: string;
|
||||
@@ -237,3 +240,30 @@ export function _getFontFamily (fontHandle: string): string {
|
||||
}
|
||||
return fontFamilyName;
|
||||
}
|
||||
|
||||
function createFont (id: string, data: string, options: IDownloadParseOptions, onComplete: CompleteCallback<TTFFont>) {
|
||||
const out = new TTFFont();
|
||||
out._nativeUrl = id;
|
||||
out._nativeAsset = data;
|
||||
onComplete(null, out);
|
||||
}
|
||||
|
||||
downloader.register({
|
||||
// font
|
||||
'.font': loadFont,
|
||||
'.eot': loadFont,
|
||||
'.ttf': loadFont,
|
||||
'.woff': loadFont,
|
||||
'.svg': loadFont,
|
||||
'.ttc': loadFont,
|
||||
});
|
||||
|
||||
factory.register({
|
||||
// font
|
||||
'.font': createFont,
|
||||
'.eot': createFont,
|
||||
'.ttf': createFont,
|
||||
'.woff': createFont,
|
||||
'.svg': createFont,
|
||||
'.ttc': createFont,
|
||||
});
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
import { TEST } from 'internal:constants';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
import './font-loader';
|
||||
export * from './html-text-parser';
|
||||
export * from './text-utils';
|
||||
@@ -23,8 +23,26 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
export * from './skeletal-animation-utils';
|
||||
export * from './skinning-model';
|
||||
export * from './baked-skinning-model';
|
||||
export * from './morph-model';
|
||||
import { removeProperty, replaceProperty } from '../../core/utils';
|
||||
import { Mesh } from './mesh';
|
||||
|
||||
replaceProperty(Mesh.prototype, 'Mesh.prototype', [
|
||||
{
|
||||
name: 'renderingMesh',
|
||||
newName: 'renderingSubMeshes',
|
||||
},
|
||||
]);
|
||||
|
||||
removeProperty(Mesh.prototype, 'Mesh.prototype', [
|
||||
{
|
||||
name: 'hasFlatBuffers',
|
||||
},
|
||||
{
|
||||
name: 'destroyFlatBuffers',
|
||||
},
|
||||
]);
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
export { Mesh } from './mesh';
|
||||
export { Skeleton } from './skeleton';
|
||||
import './deprecated';
|
||||
@@ -29,18 +29,18 @@
|
||||
*/
|
||||
|
||||
import { ccclass, serializable } from 'cc.decorator';
|
||||
import { Asset } from './asset';
|
||||
import { BufferBlob } from '../3d/misc/buffer-blob';
|
||||
import { Asset } from '../../core/assets/asset';
|
||||
import { BufferBlob } from '../misc/buffer-blob';
|
||||
import { Skeleton } from './skeleton';
|
||||
import { AABB } from '../geometry';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { mapBuffer } from '../3d/misc/buffer';
|
||||
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
|
||||
import { sys } from '../platform/sys';
|
||||
import { warnID } from '../platform/debug';
|
||||
import { AABB } from '../../core/geometry';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { murmurhash2_32_gc } from '../../core/utils/murmurhash2_gc';
|
||||
import { sys } from '../../core/platform/sys';
|
||||
import { warnID } from '../../core/platform/debug';
|
||||
import { RenderingSubMesh } from '../../core/assets';
|
||||
import {
|
||||
Attribute, Device, InputAssemblerInfo, Buffer, BufferInfo,
|
||||
} from '../gfx';
|
||||
} from '../../core/gfx';
|
||||
import {
|
||||
AttributeName,
|
||||
BufferUsageBit,
|
||||
@@ -51,13 +51,9 @@ import {
|
||||
MemoryUsageBit,
|
||||
PrimitiveMode,
|
||||
getTypedArrayConstructor,
|
||||
} from '../gfx/define';
|
||||
} from '../../core/gfx/define';
|
||||
|
||||
import {
|
||||
FlatBufferArrayPool, FlatBufferPool, FlatBufferView, NULL_HANDLE, RawBufferPool,
|
||||
SubMeshHandle, SubMeshPool, SubMeshView, freeHandleArray,
|
||||
} from '../renderer/core/memory-pools';
|
||||
import { Mat4, Quat, Vec3 } from '../math';
|
||||
import { Mat4, Quat, Vec3 } from '../../core/math';
|
||||
import { Morph, MorphRendering, createMorphRendering } from './morph';
|
||||
|
||||
function getIndexStrideCtor (stride: number) {
|
||||
@@ -69,370 +65,6 @@ function getIndexStrideCtor (stride: number) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Array views for index buffer
|
||||
* @zh 允许存储索引的数组视图。
|
||||
*/
|
||||
export type IBArray = Uint8Array | Uint16Array | Uint32Array;
|
||||
|
||||
/**
|
||||
* @en The interface of geometric information
|
||||
* @zh 几何信息。
|
||||
*/
|
||||
export interface IGeometricInfo {
|
||||
/**
|
||||
* @en Vertex positions
|
||||
* @zh 顶点位置。
|
||||
*/
|
||||
positions: Float32Array;
|
||||
|
||||
/**
|
||||
* @en Indices data
|
||||
* @zh 索引数据。
|
||||
*/
|
||||
indices?: IBArray;
|
||||
|
||||
/**
|
||||
* @en Whether the geometry is treated as double sided
|
||||
* @zh 是否将图元按双面对待。
|
||||
*/
|
||||
doubleSided?: boolean;
|
||||
|
||||
/**
|
||||
* @en The bounding box
|
||||
* @zh 此几何体的轴对齐包围盒。
|
||||
*/
|
||||
boundingBox: { max: Vec3; min: Vec3 };
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Flat vertex buffer
|
||||
* @zh 扁平化顶点缓冲区
|
||||
*/
|
||||
export interface IFlatBuffer {
|
||||
stride: number;
|
||||
count: number;
|
||||
buffer: Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Sub mesh for rendering which contains all geometry data, it can be used to create [[InputAssembler]].
|
||||
* @zh 包含所有顶点数据的渲染子网格,可以用来创建 [[InputAssembler]]。
|
||||
*/
|
||||
export class RenderingSubMesh {
|
||||
public mesh?: Mesh;
|
||||
|
||||
public subMeshIdx?: number;
|
||||
|
||||
private _flatBuffers: IFlatBuffer[] = [];
|
||||
|
||||
private _jointMappedBuffers?: Buffer[];
|
||||
|
||||
private _jointMappedBufferIndices?: number[];
|
||||
|
||||
private _vertexIdChannel?: { stream: number; index: number };
|
||||
|
||||
private _geometricInfo?: IGeometricInfo;
|
||||
|
||||
private _vertexBuffers: Buffer[];
|
||||
|
||||
private _attributes: Attribute[];
|
||||
|
||||
private _indexBuffer: Buffer | null = null;
|
||||
|
||||
private _indirectBuffer: Buffer | null = null;
|
||||
|
||||
private _primitiveMode: PrimitiveMode;
|
||||
|
||||
private _iaInfo: InputAssemblerInfo;
|
||||
|
||||
private _handle: SubMeshHandle = NULL_HANDLE;
|
||||
|
||||
constructor (
|
||||
vertexBuffers: Buffer[], attributes: Attribute[], primitiveMode: PrimitiveMode,
|
||||
indexBuffer: Buffer | null = null, indirectBuffer: Buffer | null = null,
|
||||
) {
|
||||
this._attributes = attributes;
|
||||
this._vertexBuffers = vertexBuffers;
|
||||
this._indexBuffer = indexBuffer;
|
||||
this._indirectBuffer = indirectBuffer;
|
||||
this._primitiveMode = primitiveMode;
|
||||
this._iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer);
|
||||
this._handle = SubMeshPool.alloc();
|
||||
const fbArrayHandle = FlatBufferArrayPool.alloc();
|
||||
SubMeshPool.set(this._handle, SubMeshView.FLAT_BUFFER_ARRAY, fbArrayHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @en All vertex attributes used by the sub mesh
|
||||
* @zh 所有顶点属性。
|
||||
*/
|
||||
get attributes () { return this._attributes; }
|
||||
|
||||
/**
|
||||
* @en All vertex buffers used by the sub mesh
|
||||
* @zh 使用的所有顶点缓冲区。
|
||||
*/
|
||||
get vertexBuffers () { return this._vertexBuffers; }
|
||||
|
||||
/**
|
||||
* @en Index buffer used by the sub mesh
|
||||
* @zh 使用的索引缓冲区,若未使用则无需指定。
|
||||
*/
|
||||
get indexBuffer () { return this._indexBuffer; }
|
||||
|
||||
/**
|
||||
* @en Indirect buffer used by the sub mesh
|
||||
* @zh 间接绘制缓冲区。
|
||||
*/
|
||||
get indirectBuffer () { return this._indirectBuffer; }
|
||||
|
||||
/**
|
||||
* @en Primitive mode used by the sub mesh
|
||||
* @zh 图元类型。
|
||||
*/
|
||||
get primitiveMode () { return this._primitiveMode; }
|
||||
|
||||
/**
|
||||
* @en The geometric info of the sub mesh, used for raycast.
|
||||
* @zh (用于射线检测的)几何信息。
|
||||
*/
|
||||
get geometricInfo () {
|
||||
if (this._geometricInfo) {
|
||||
return this._geometricInfo;
|
||||
}
|
||||
if (this.mesh === undefined) {
|
||||
return { positions: new Float32Array(), indices: new Uint8Array(), boundingBox: { min: Vec3.ZERO, max: Vec3.ZERO } };
|
||||
}
|
||||
if (this.subMeshIdx === undefined) {
|
||||
return { positions: new Float32Array(), indices: new Uint8Array(), boundingBox: { min: Vec3.ZERO, max: Vec3.ZERO } };
|
||||
}
|
||||
const { mesh } = this; const index = this.subMeshIdx;
|
||||
const positions = mesh.readAttribute(index, AttributeName.ATTR_POSITION) as unknown as Float32Array;
|
||||
const indices = mesh.readIndices(index) as Uint16Array;
|
||||
const max = new Vec3();
|
||||
const min = new Vec3();
|
||||
const pAttri = this.attributes.find((element) => element.name === AttributeName.ATTR_POSITION);
|
||||
if (pAttri) {
|
||||
const conut = FormatInfos[pAttri.format].count;
|
||||
if (conut === 2) {
|
||||
max.set(positions[0], positions[1], 0);
|
||||
min.set(positions[0], positions[1], 0);
|
||||
} else {
|
||||
max.set(positions[0], positions[1], positions[2]);
|
||||
min.set(positions[0], positions[1], positions[2]);
|
||||
}
|
||||
for (let i = 0; i < positions.length; i += conut) {
|
||||
if (conut === 2) {
|
||||
max.x = positions[i] > max.x ? positions[i] : max.x;
|
||||
max.y = positions[i + 1] > max.y ? positions[i + 1] : max.y;
|
||||
min.x = positions[i] < min.x ? positions[i] : min.x;
|
||||
min.y = positions[i + 1] < min.y ? positions[i + 1] : min.y;
|
||||
} else {
|
||||
max.x = positions[i] > max.x ? positions[i] : max.x;
|
||||
max.y = positions[i + 1] > max.y ? positions[i + 1] : max.y;
|
||||
max.z = positions[i + 2] > max.z ? positions[i + 2] : max.z;
|
||||
min.x = positions[i] < min.x ? positions[i] : min.x;
|
||||
min.y = positions[i + 1] < min.y ? positions[i + 1] : min.y;
|
||||
min.z = positions[i + 2] < min.z ? positions[i + 2] : min.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._geometricInfo = { positions, indices, boundingBox: { max, min } };
|
||||
return this._geometricInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Flatted vertex buffers
|
||||
* @zh 扁平化的顶点缓冲区。
|
||||
*/
|
||||
get flatBuffers () { return this._flatBuffers; }
|
||||
|
||||
public genFlatBuffers () {
|
||||
if (this._flatBuffers.length || !this.mesh || this.subMeshIdx === undefined) { return; }
|
||||
|
||||
const { mesh } = this;
|
||||
let idxCount = 0;
|
||||
const prim = mesh.struct.primitives[this.subMeshIdx];
|
||||
const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY);
|
||||
if (prim.indexView) { idxCount = prim.indexView.count; }
|
||||
for (let i = 0; i < prim.vertexBundelIndices.length; i++) {
|
||||
const bundleIdx = prim.vertexBundelIndices[i];
|
||||
const vertexBundle = mesh.struct.vertexBundles[bundleIdx];
|
||||
const vbCount = prim.indexView ? prim.indexView.count : vertexBundle.view.count;
|
||||
const vbStride = vertexBundle.view.stride;
|
||||
const vbSize = vbStride * vbCount;
|
||||
const view = new Uint8Array(mesh.data.buffer, vertexBundle.view.offset, vertexBundle.view.length);
|
||||
|
||||
const hBuffer = RawBufferPool.alloc(prim.indexView ? vbSize : vertexBundle.view.length);
|
||||
const hFlatBuffer = FlatBufferPool.alloc();
|
||||
FlatBufferPool.set(hFlatBuffer, FlatBufferView.STRIDE, vbStride);
|
||||
FlatBufferPool.set(hFlatBuffer, FlatBufferView.AMOUNT, vbCount);
|
||||
FlatBufferPool.set(hFlatBuffer, FlatBufferView.BUFFER, hBuffer);
|
||||
FlatBufferArrayPool.push(fbArrayHandle, hFlatBuffer);
|
||||
|
||||
const buffer = RawBufferPool.getBuffer(hBuffer);
|
||||
const sharedView = new Uint8Array(buffer);
|
||||
|
||||
if (!prim.indexView) {
|
||||
sharedView.set(mesh.data.subarray(vertexBundle.view.offset, vertexBundle.view.offset + vertexBundle.view.length));
|
||||
this._flatBuffers.push({ stride: vbStride, count: vbCount, buffer: sharedView });
|
||||
continue;
|
||||
}
|
||||
|
||||
const ibView = mesh.readIndices(this.subMeshIdx)!;
|
||||
// transform to flat buffer
|
||||
for (let n = 0; n < idxCount; ++n) {
|
||||
const idx = ibView[n];
|
||||
const offset = n * vbStride;
|
||||
const srcOffset = idx * vbStride;
|
||||
for (let m = 0; m < vbStride; ++m) {
|
||||
sharedView[offset + m] = view[srcOffset + m];
|
||||
}
|
||||
}
|
||||
this._flatBuffers.push({ stride: vbStride, count: vbCount, buffer: sharedView });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @en The vertex buffer for joint after mapping
|
||||
* @zh 骨骼索引按映射表处理后的顶点缓冲。
|
||||
*/
|
||||
get jointMappedBuffers () {
|
||||
if (this._jointMappedBuffers) { return this._jointMappedBuffers; }
|
||||
const buffers: Buffer[] = this._jointMappedBuffers = [];
|
||||
const indices: number[] = this._jointMappedBufferIndices = [];
|
||||
if (!this.mesh || this.subMeshIdx === undefined) { return this._jointMappedBuffers = this.vertexBuffers; }
|
||||
const { struct } = this.mesh;
|
||||
const prim = struct.primitives[this.subMeshIdx];
|
||||
if (!struct.jointMaps || prim.jointMapIndex === undefined || !struct.jointMaps[prim.jointMapIndex]) {
|
||||
return this._jointMappedBuffers = this.vertexBuffers;
|
||||
}
|
||||
let jointFormat: Format;
|
||||
let jointOffset: number;
|
||||
const { device } = legacyCC.director.root;
|
||||
for (let i = 0; i < prim.vertexBundelIndices.length; i++) {
|
||||
const bundle = struct.vertexBundles[prim.vertexBundelIndices[i]];
|
||||
jointOffset = 0;
|
||||
jointFormat = Format.UNKNOWN;
|
||||
for (let j = 0; j < bundle.attributes.length; j++) {
|
||||
const attr = bundle.attributes[j];
|
||||
if (attr.name === AttributeName.ATTR_JOINTS) {
|
||||
jointFormat = attr.format;
|
||||
break;
|
||||
}
|
||||
jointOffset += FormatInfos[attr.format].size;
|
||||
}
|
||||
if (jointFormat) {
|
||||
const data = new Uint8Array(this.mesh.data.buffer, bundle.view.offset, bundle.view.length);
|
||||
const dataView = new DataView(data.slice().buffer);
|
||||
const idxMap = struct.jointMaps[prim.jointMapIndex];
|
||||
mapBuffer(dataView, (cur) => idxMap.indexOf(cur), jointFormat, jointOffset,
|
||||
bundle.view.length, bundle.view.stride, dataView);
|
||||
const buffer = device.createBuffer(new BufferInfo(
|
||||
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
|
||||
MemoryUsageBit.DEVICE,
|
||||
bundle.view.length,
|
||||
bundle.view.stride,
|
||||
));
|
||||
buffer.update(dataView.buffer); buffers.push(buffer); indices.push(i);
|
||||
} else {
|
||||
buffers.push(this.vertexBuffers[prim.vertexBundelIndices[i]]);
|
||||
}
|
||||
}
|
||||
if (this._vertexIdChannel) {
|
||||
buffers.push(this._allocVertexIdBuffer(device));
|
||||
}
|
||||
return buffers;
|
||||
}
|
||||
|
||||
get iaInfo () { return this._iaInfo; }
|
||||
|
||||
get handle () {
|
||||
return this._handle;
|
||||
}
|
||||
|
||||
public destroy () {
|
||||
for (let i = 0; i < this.vertexBuffers.length; i++) {
|
||||
this.vertexBuffers[i].destroy();
|
||||
}
|
||||
this.vertexBuffers.length = 0;
|
||||
if (this._indexBuffer) {
|
||||
this._indexBuffer.destroy();
|
||||
this._indexBuffer = null;
|
||||
}
|
||||
if (this._jointMappedBuffers && this._jointMappedBufferIndices) {
|
||||
for (let i = 0; i < this._jointMappedBufferIndices.length; i++) {
|
||||
this._jointMappedBuffers[this._jointMappedBufferIndices[i]].destroy();
|
||||
}
|
||||
this._jointMappedBuffers = undefined;
|
||||
this._jointMappedBufferIndices = undefined;
|
||||
}
|
||||
if (this._indirectBuffer) {
|
||||
this._indirectBuffer.destroy();
|
||||
this._indirectBuffer = null;
|
||||
}
|
||||
if (this._handle) {
|
||||
const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY);
|
||||
freeHandleArray(fbArrayHandle, FlatBufferArrayPool, FlatBufferPool);
|
||||
|
||||
SubMeshPool.free(this._handle);
|
||||
this._handle = NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Adds a vertex attribute input called 'a_vertexId' into this sub-mesh.
|
||||
* This is useful if you want to simulate `gl_VertexId` in WebGL context prior to 2.0.
|
||||
* Once you call this function, the vertex attribute is permanently added.
|
||||
* Subsequent calls to this function take no effect.
|
||||
* @param device Device used to create related rendering resources.
|
||||
*/
|
||||
public enableVertexIdChannel (device: Device) {
|
||||
if (this._vertexIdChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const streamIndex = this.vertexBuffers.length;
|
||||
const attributeIndex = this.attributes.length;
|
||||
|
||||
const vertexIdBuffer = this._allocVertexIdBuffer(device);
|
||||
this._vertexBuffers.push(vertexIdBuffer);
|
||||
this._attributes.push(new Attribute('a_vertexId', Format.R32F, false, streamIndex));
|
||||
|
||||
this._iaInfo.attributes = this._attributes;
|
||||
this._iaInfo.vertexBuffers = this._vertexBuffers;
|
||||
|
||||
this._vertexIdChannel = {
|
||||
stream: streamIndex,
|
||||
index: attributeIndex,
|
||||
};
|
||||
}
|
||||
|
||||
private _allocVertexIdBuffer (device: Device) {
|
||||
const vertexCount = (this.vertexBuffers.length === 0 || this.vertexBuffers[0].stride === 0)
|
||||
? 0
|
||||
// TODO: This depends on how stride of a vertex buffer is defined; Consider padding problem.
|
||||
: this.vertexBuffers[0].size / this.vertexBuffers[0].stride;
|
||||
const vertexIds = new Float32Array(vertexCount);
|
||||
for (let iVertex = 0; iVertex < vertexCount; ++iVertex) {
|
||||
// `+0.5` because on some platforms, the "fetched integer" may have small error.
|
||||
// For example `26` may yield `25.99999`, which is convert to `25` instead of `26` using `int()`.
|
||||
vertexIds[iVertex] = iVertex + 0.5;
|
||||
}
|
||||
|
||||
const vertexIdBuffer = device.createBuffer(new BufferInfo(
|
||||
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
|
||||
MemoryUsageBit.DEVICE,
|
||||
vertexIds.byteLength,
|
||||
vertexIds.BYTES_PER_ELEMENT,
|
||||
));
|
||||
vertexIdBuffer.update(vertexIds);
|
||||
|
||||
return vertexIdBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
export declare namespace Mesh {
|
||||
export interface IBufferView {
|
||||
offset: number;
|
||||
@@ -28,20 +28,20 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { AttributeName, Buffer, BufferUsageBit, Device, Feature, MemoryUsageBit, DescriptorSet, BufferInfo } from '../gfx';
|
||||
import { AttributeName, Buffer, BufferUsageBit, Device, Feature, MemoryUsageBit, DescriptorSet, BufferInfo } from '../../core/gfx';
|
||||
import { Mesh } from './mesh';
|
||||
import { Texture2D } from './texture-2d';
|
||||
import { ImageAsset } from './image-asset';
|
||||
import { samplerLib } from '../renderer/core/sampler-lib';
|
||||
import { UBOMorph, UNIFORM_NORMAL_MORPH_TEXTURE_BINDING, UNIFORM_POSITION_MORPH_TEXTURE_BINDING, UNIFORM_TANGENT_MORPH_TEXTURE_BINDING } from '../pipeline/define';
|
||||
import { warn, warnID } from '../platform/debug';
|
||||
import { Texture2D } from '../../core/assets/texture-2d';
|
||||
import { ImageAsset } from '../../core/assets/image-asset';
|
||||
import { samplerLib } from '../../core/renderer/core/sampler-lib';
|
||||
import { UBOMorph, UNIFORM_NORMAL_MORPH_TEXTURE_BINDING, UNIFORM_POSITION_MORPH_TEXTURE_BINDING, UNIFORM_TANGENT_MORPH_TEXTURE_BINDING } from '../../core/pipeline/define';
|
||||
import { warn, warnID } from '../../core/platform/debug';
|
||||
import { Morph, MorphRendering, MorphRenderingInstance, SubMeshMorph } from './morph';
|
||||
import { assertIsNonNullable, assertIsTrue } from '../data/utils/asserts';
|
||||
import { log2, nextPow2 } from '../math/bits';
|
||||
import { IMacroPatch } from '../renderer';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { PixelFormat } from './asset-enum';
|
||||
import { DSPool } from '../renderer/core/memory-pools';
|
||||
import { assertIsNonNullable, assertIsTrue } from '../../core/data/utils/asserts';
|
||||
import { log2, nextPow2 } from '../../core/math/bits';
|
||||
import { IMacroPatch } from '../../core/renderer';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { PixelFormat } from '../../core/assets/asset-enum';
|
||||
import { DSPool } from '../../core/renderer/core/memory-pools';
|
||||
|
||||
/**
|
||||
* True if force to use cpu computing based sub-mesh rendering.
|
||||
@@ -28,10 +28,10 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { AttributeName, Device, DescriptorSet } from '../gfx';
|
||||
import { AttributeName, Device, DescriptorSet } from '../../core/gfx';
|
||||
import { Mesh } from './mesh';
|
||||
import { StdMorphRendering } from './morph-rendering';
|
||||
import { IMacroPatch } from '../renderer';
|
||||
import { IMacroPatch } from '../../core/renderer';
|
||||
|
||||
export interface Morph {
|
||||
/**
|
||||
@@ -32,9 +32,9 @@ import { ccclass, type, serializable } from 'cc.decorator';
|
||||
import { CCString } from '../../core/data/utils/attribute';
|
||||
import { Mat4 } from '../../core/math';
|
||||
import { murmurhash2_32_gc } from '../../core/utils/murmurhash2_gc';
|
||||
import { DataPoolManager } from '../renderer/data-pool-manager';
|
||||
import { Asset } from './asset';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { DataPoolManager } from '../skeletal-animation/data-pool-manager';
|
||||
import { Asset } from '../../core/assets/asset';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
/**
|
||||
* @en The skeleton asset. It stores the path related to [[SkinnedMeshRenderer.skinningRoot]] of all bones and its bind pose matrix.
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module component
|
||||
*/
|
||||
|
||||
import { removeProperty, replaceProperty } from '../../core/utils';
|
||||
import { MeshRenderer } from './mesh-renderer';
|
||||
import { js } from '../../core/utils/js';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
removeProperty(MeshRenderer.prototype, 'MeshRenderer.prototype', [
|
||||
{
|
||||
name: 'enableDynamicBatching',
|
||||
},
|
||||
{
|
||||
name: 'recieveShadows',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Alias of [[MeshRenderer]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { MeshRenderer as ModelComponent };
|
||||
legacyCC.ModelComponent = MeshRenderer;
|
||||
js.setClassAlias(MeshRenderer, 'cc.ModelComponent');
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
export { MeshRenderer } from './mesh-renderer';
|
||||
|
||||
/** deprecated */
|
||||
export * from './deprecated';
|
||||
@@ -28,20 +28,21 @@
|
||||
* @module model
|
||||
*/
|
||||
|
||||
import { Texture2D } from '../../assets';
|
||||
import { Material } from '../../assets/material';
|
||||
import { Mesh } from '../../assets/mesh';
|
||||
import { ccclass, help, executeInEditMode, executionOrder, menu, tooltip, visible, type, formerlySerializedAs, serializable, editable, disallowAnimation } from 'cc.decorator';
|
||||
import { Vec4 } from '../../math';
|
||||
import { scene, models } from '../../renderer';
|
||||
import { Root } from '../../root';
|
||||
import { TransformBit } from '../../scene-graph/node-enum';
|
||||
import { Enum } from '../../value-types';
|
||||
import { builtinResMgr } from '../builtin';
|
||||
import { RenderableComponent } from './renderable-component';
|
||||
import { MorphRenderingInstance } from '../../assets/morph';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
import { assertIsTrue } from '../../data/utils/asserts';
|
||||
import { Texture2D } from '../../core/assets';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { Vec4 } from '../../core/math';
|
||||
import { scene } from '../../core/renderer';
|
||||
import { MorphModel } from '../models/morph-model';
|
||||
import { Root } from '../../core/root';
|
||||
import { TransformBit } from '../../core/scene-graph/node-enum';
|
||||
import { Enum } from '../../core/value-types';
|
||||
import { builtinResMgr } from '../../core/builtin';
|
||||
import { RenderableComponent } from '../../core/components/renderable-component';
|
||||
import { MorphRenderingInstance } from '../assets/morph';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { assertIsTrue } from '../../core/data/utils/asserts';
|
||||
|
||||
/**
|
||||
* @en Shadow projection mode.
|
||||
@@ -159,7 +160,6 @@ class ModelLightmapSettings {
|
||||
@menu('Components/MeshRenderer')
|
||||
@executeInEditMode
|
||||
export class MeshRenderer extends RenderableComponent {
|
||||
|
||||
public static ShadowCastingMode = ModelShadowCastingMode;
|
||||
public static ShadowReceivingMode = ModelShadowReceivingMode;
|
||||
|
||||
@@ -361,13 +361,13 @@ export class MeshRenderer extends RenderableComponent {
|
||||
// Please notice that we do not enforce that
|
||||
// derived classes should use a morph-able model type(i.e. model type derived from `MorphModel`).
|
||||
// So we should take care of the edge case.
|
||||
const modelType = (preferMorphOverPlain && this._modelType === scene.Model) ? models.MorphModel : this._modelType;
|
||||
const modelType = (preferMorphOverPlain && this._modelType === scene.Model) ? MorphModel : this._modelType;
|
||||
const model = this._model! = (legacyCC.director.root as Root).createModel(modelType);
|
||||
model.visFlags = this.visibility;
|
||||
model.node = model.transform = this.node;
|
||||
this._models.length = 0;
|
||||
this._models.push(this._model);
|
||||
if (this._morphInstance && model instanceof models.MorphModel) {
|
||||
if (this._morphInstance && model instanceof MorphModel) {
|
||||
model.setMorphRendering(this._morphInstance);
|
||||
}
|
||||
}
|
||||
@@ -522,7 +522,7 @@ export class MeshRenderer extends RenderableComponent {
|
||||
this._morphInstance.setWeights(iSubMesh, weights);
|
||||
}
|
||||
|
||||
if (this._model && this._model instanceof models.MorphModel) {
|
||||
if (this._model && this._model instanceof MorphModel) {
|
||||
this._model.setMorphRendering(this._morphInstance);
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,16 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
export * from './builtin';
|
||||
export * from './framework';
|
||||
import * as utils from './misc/utils';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import * as utils from './misc';
|
||||
import { legacyCC } from '../core/global-exports';
|
||||
|
||||
export * from './misc/batch-utils';
|
||||
export * from './assets';
|
||||
export * from './framework';
|
||||
|
||||
export * from './lights';
|
||||
export * from './skinned-mesh-renderer';
|
||||
export * from './skeletal-animation';
|
||||
export {
|
||||
utils,
|
||||
};
|
||||
@@ -25,35 +25,41 @@
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
* @module component
|
||||
*/
|
||||
|
||||
export { Button } from './button';
|
||||
export { EditBox } from './editbox/edit-box';
|
||||
export * from './label';
|
||||
export { Layout } from './layout';
|
||||
export { Mask } from './mask';
|
||||
export { ProgressBar } from './progress-bar';
|
||||
export { RichText } from './rich-text';
|
||||
export { ScrollBar } from './scroll-bar';
|
||||
export { ScrollView } from './scroll-view';
|
||||
export { Slider } from './slider';
|
||||
export { Sprite } from './sprite';
|
||||
export { Toggle } from './toggle';
|
||||
export { ToggleContainer } from './toggle-container';
|
||||
export { UIMeshRenderer } from './ui-mesh-renderer';
|
||||
export { ViewGroup } from './view-group';
|
||||
export { Widget } from './widget';
|
||||
export { LabelOutline } from './label-outline';
|
||||
export { Graphics } from './graphics';
|
||||
export { PageView } from './page-view';
|
||||
export { PageViewIndicator } from './page-view-indicator';
|
||||
export { UIStaticBatch } from './ui-static-batch';
|
||||
export { UIOpacity } from './ui-opacity';
|
||||
export { SafeArea } from './safe-area';
|
||||
export { UICoordinateTracker } from './ui-coodinate-tracker';
|
||||
export { BlockInputEvents } from './block-input-events';
|
||||
export { LabelShadow } from './label-shadow';
|
||||
export { SubContextView } from './SubContextView';
|
||||
import { Light } from './light-component';
|
||||
import { SpotLight } from './spot-light-component';
|
||||
import { SphereLight } from './sphere-light-component';
|
||||
import { DirectionalLight } from './directional-light-component';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { js } from '../../core/utils/js';
|
||||
|
||||
export { widgetManager } from './widget-manager';
|
||||
/**
|
||||
* Alias of [[Light]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { Light as LightComponent };
|
||||
legacyCC.LightComponent = Light;
|
||||
js.setClassAlias(Light, 'cc.LightComponent');
|
||||
/**
|
||||
* Alias of [[DirectionalLight]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { DirectionalLight as DirectionalLightComponent };
|
||||
legacyCC.DirectionalLightComponent = DirectionalLight;
|
||||
js.setClassAlias(DirectionalLight, 'cc.DirectionalLightComponent');
|
||||
/**
|
||||
* Alias of [[SphereLight]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { SphereLight as SphereLightComponent };
|
||||
legacyCC.SphereLightComponent = SphereLight;
|
||||
js.setClassAlias(SphereLight, 'cc.SphereLightComponent');
|
||||
/**
|
||||
* Alias of [[SpotLight]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { SpotLight as SpotLightComponent };
|
||||
legacyCC.SpotLightComponent = SpotLight;
|
||||
js.setClassAlias(SpotLight, 'cc.SpotLightComponent');
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
import { ccclass, help, executeInEditMode, menu, tooltip, unit, serializable } from 'cc.decorator';
|
||||
import { scene } from '../../renderer';
|
||||
import { scene } from '../../core/renderer';
|
||||
import { Light } from './light-component';
|
||||
|
||||
@ccclass('cc.DirectionalLight')
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
export { DirectionalLight } from './directional-light-component';
|
||||
export { Light } from './light-component';
|
||||
export { SphereLight } from './sphere-light-component';
|
||||
export { SpotLight } from './spot-light-component';
|
||||
|
||||
/** deprecated */
|
||||
export * from './deprecated';
|
||||
@@ -28,14 +28,14 @@
|
||||
* @module component/light
|
||||
*/
|
||||
|
||||
import { Component } from '../../components/component';
|
||||
import { Component } from '../../core/components/component';
|
||||
import { ccclass, tooltip, range, slide, type, serializable, editable } from 'cc.decorator';
|
||||
import { Color, Vec3 } from '../../math';
|
||||
import { Enum } from '../../value-types';
|
||||
import { Color, Vec3 } from '../../core/math';
|
||||
import { Enum } from '../../core/value-types';
|
||||
|
||||
import { scene } from '../../renderer';
|
||||
import { Root } from '../../root';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
import { scene } from '../../core/renderer';
|
||||
import { Root } from '../../core/root';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
export const PhotometricTerm = Enum({
|
||||
LUMINOUS_POWER: 0,
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
import { ccclass, help, executeInEditMode, menu, tooltip, type, unit, serializable } from 'cc.decorator';
|
||||
import { scene } from '../../renderer';
|
||||
import { scene } from '../../core/renderer';
|
||||
import { Light, PhotometricTerm } from './light-component';
|
||||
|
||||
@ccclass('cc.SphereLight')
|
||||
+2
-2
@@ -31,8 +31,8 @@
|
||||
import {
|
||||
ccclass, help, executeInEditMode, menu, tooltip, type, slide, range, unit, serializable,
|
||||
} from 'cc.decorator';
|
||||
import { toRadian } from '../../math';
|
||||
import { scene } from '../../renderer';
|
||||
import { toRadian } from '../../core/math';
|
||||
import { scene } from '../../core/renderer';
|
||||
import { Light, PhotometricTerm } from './light-component';
|
||||
|
||||
@ccclass('cc.SpotLight')
|
||||
@@ -23,92 +23,92 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module core
|
||||
*/
|
||||
|
||||
import { MeshRenderer } from '../3d/framework/mesh-renderer';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { Mat4 } from '../math/mat4';
|
||||
import { Node } from '../scene-graph/node';
|
||||
|
||||
function checkMaterialisSame (comp1: MeshRenderer, comp2: MeshRenderer): boolean {
|
||||
const matNum = comp1.sharedMaterials.length;
|
||||
if (matNum !== comp2.sharedMaterials.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < matNum; i++) {
|
||||
if (comp1.getRenderMaterial(i) !== comp2.getRenderMaterial(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Utility for 3d model static batching
|
||||
* @zh 服务于 3D 模型静态合批的工具类
|
||||
*/
|
||||
export class BatchingUtility {
|
||||
/**
|
||||
* Collect the Models under `staticModelRoot`,
|
||||
* merge all the meshes statically into one (while disabling each component),
|
||||
* and attach it to a new Model on `batchedRoot`.
|
||||
* The world transform of each model is guaranteed to be preserved.
|
||||
*
|
||||
* For a more fine-grained control over the process, use `Mesh.merge` directly.
|
||||
* @param staticModelRoot root of all the static models to be batched
|
||||
* @param batchedRoot the target output node
|
||||
*/
|
||||
public static batchStaticModel (staticModelRoot: Node, batchedRoot: Node) {
|
||||
const models = staticModelRoot.getComponentsInChildren(MeshRenderer);
|
||||
if (models.length < 2) {
|
||||
console.error('the number of static models to batch is less than 2,it needn\'t batch.');
|
||||
return false;
|
||||
}
|
||||
for (let i = 1; i < models.length; i++) {
|
||||
if (!models[0].mesh!.validateMergingMesh(models[i].mesh!)) {
|
||||
console.error('the meshes of ' + models[0].node.name + ' and ' + models[i].node.name + ' can\'t be merged');
|
||||
return false;
|
||||
}
|
||||
if (!checkMaterialisSame(models[0], models[i])) {
|
||||
console.error('the materials of ' + models[0].node.name + ' and ' + models[i].node.name + ' can\'t be merged');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const batchedMesh = new Mesh();
|
||||
const worldMat = new Mat4();
|
||||
const rootWorldMatInv = new Mat4();
|
||||
staticModelRoot.getWorldMatrix(rootWorldMatInv);
|
||||
Mat4.invert(rootWorldMatInv, rootWorldMatInv);
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
const comp = models[i];
|
||||
comp.node.getWorldMatrix(worldMat);
|
||||
Mat4.multiply(worldMat, rootWorldMatInv, worldMat);
|
||||
batchedMesh.merge(models[i].mesh!, worldMat);
|
||||
comp.enabled = false;
|
||||
}
|
||||
const batchedModel = batchedRoot.addComponent(MeshRenderer);
|
||||
batchedModel.mesh = batchedMesh;
|
||||
batchedModel.sharedMaterials = models[0].sharedMaterials;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undoes everything `batchStaticModel` did.
|
||||
*
|
||||
* @param staticModelRoot root of all the static models to be batched
|
||||
* @param batchedRoot the target output node
|
||||
*/
|
||||
public static unbatchStaticModel (staticModelRoot: Node, batchedRoot: Node) {
|
||||
const models = staticModelRoot.getComponentsInChildren('cc.MeshRenderer');
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
const comp = models[i];
|
||||
comp.enabled = true;
|
||||
}
|
||||
const batchedModel = batchedRoot.getComponent('cc.MeshRenderer');
|
||||
if (batchedModel) { batchedModel.destroy(); }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module core
|
||||
*/
|
||||
|
||||
import { MeshRenderer } from '../framework/mesh-renderer';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { Mat4 } from '../../core/math/mat4';
|
||||
import { Node } from '../../core/scene-graph/node';
|
||||
|
||||
function checkMaterialisSame (comp1: MeshRenderer, comp2: MeshRenderer): boolean {
|
||||
const matNum = comp1.sharedMaterials.length;
|
||||
if (matNum !== comp2.sharedMaterials.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < matNum; i++) {
|
||||
if (comp1.getRenderMaterial(i) !== comp2.getRenderMaterial(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Utility for 3d model static batching
|
||||
* @zh 服务于 3D 模型静态合批的工具类
|
||||
*/
|
||||
export class BatchingUtility {
|
||||
/**
|
||||
* Collect the Models under `staticModelRoot`,
|
||||
* merge all the meshes statically into one (while disabling each component),
|
||||
* and attach it to a new Model on `batchedRoot`.
|
||||
* The world transform of each model is guaranteed to be preserved.
|
||||
*
|
||||
* For a more fine-grained control over the process, use `Mesh.merge` directly.
|
||||
* @param staticModelRoot root of all the static models to be batched
|
||||
* @param batchedRoot the target output node
|
||||
*/
|
||||
public static batchStaticModel (staticModelRoot: Node, batchedRoot: Node) {
|
||||
const models = staticModelRoot.getComponentsInChildren(MeshRenderer);
|
||||
if (models.length < 2) {
|
||||
console.error('the number of static models to batch is less than 2,it needn\'t batch.');
|
||||
return false;
|
||||
}
|
||||
for (let i = 1; i < models.length; i++) {
|
||||
if (!models[0].mesh!.validateMergingMesh(models[i].mesh!)) {
|
||||
console.error('the meshes of ' + models[0].node.name + ' and ' + models[i].node.name + ' can\'t be merged');
|
||||
return false;
|
||||
}
|
||||
if (!checkMaterialisSame(models[0], models[i])) {
|
||||
console.error('the materials of ' + models[0].node.name + ' and ' + models[i].node.name + ' can\'t be merged');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const batchedMesh = new Mesh();
|
||||
const worldMat = new Mat4();
|
||||
const rootWorldMatInv = new Mat4();
|
||||
staticModelRoot.getWorldMatrix(rootWorldMatInv);
|
||||
Mat4.invert(rootWorldMatInv, rootWorldMatInv);
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
const comp = models[i];
|
||||
comp.node.getWorldMatrix(worldMat);
|
||||
Mat4.multiply(worldMat, rootWorldMatInv, worldMat);
|
||||
batchedMesh.merge(models[i].mesh!, worldMat);
|
||||
comp.enabled = false;
|
||||
}
|
||||
const batchedModel = batchedRoot.addComponent(MeshRenderer);
|
||||
batchedModel.mesh = batchedMesh;
|
||||
batchedModel.sharedMaterials = models[0].sharedMaterials;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undoes everything `batchStaticModel` did.
|
||||
*
|
||||
* @param staticModelRoot root of all the static models to be batched
|
||||
* @param batchedRoot the target output node
|
||||
*/
|
||||
public static unbatchStaticModel (staticModelRoot: Node, batchedRoot: Node) {
|
||||
const models = staticModelRoot.getComponentsInChildren('cc.MeshRenderer');
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
const comp = models[i];
|
||||
comp.enabled = true;
|
||||
}
|
||||
const batchedModel = batchedRoot.getComponent('cc.MeshRenderer');
|
||||
if (batchedModel) { batchedModel.destroy(); }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { Format, FormatInfos, FormatType, FormatInfo } from '../../gfx/define';
|
||||
import { sys } from '../../platform/sys';
|
||||
import { Format, FormatInfos, FormatType, FormatInfo } from '../../core/gfx/define';
|
||||
import { sys } from '../../core/platform/sys';
|
||||
|
||||
const _typeMap = {
|
||||
[FormatType.UNORM]: 'Uint',
|
||||
@@ -23,10 +23,10 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { Mesh } from '../../assets/mesh';
|
||||
import { AttributeName, Format, FormatInfos, PrimitiveMode } from '../../gfx/define';
|
||||
import { Attribute } from '../../gfx';
|
||||
import { Vec3 } from '../../math';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { AttributeName, Format, FormatInfos, PrimitiveMode } from '../../core/gfx/define';
|
||||
import { Attribute } from '../../core/gfx';
|
||||
import { Vec3 } from '../../core/math';
|
||||
import { IGeometry } from '../../primitive/define';
|
||||
import { writeBuffer } from './buffer';
|
||||
import { BufferBlob } from './buffer-blob';
|
||||
@@ -23,8 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
export { find } from '../../scene-graph/find';
|
||||
export { find } from '../../core/scene-graph/find';
|
||||
export { toPPM } from './ppm';
|
||||
export { readMesh } from './read-mesh';
|
||||
export { createMesh } from './create-mesh';
|
||||
@@ -23,7 +23,6 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* save a color buffer to a PPM file
|
||||
*/
|
||||
@@ -23,9 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
import { Mesh } from '../../assets/mesh';
|
||||
import { AttributeName, Format, FormatInfos } from '../../gfx/define';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { AttributeName, Format, FormatInfos } from '../../core/gfx/define';
|
||||
import { IGeometry } from '../../primitive/define';
|
||||
import { readBuffer } from './buffer';
|
||||
|
||||
+16
-16
@@ -28,23 +28,23 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { AnimationClip } from '../../animation/animation-clip';
|
||||
import { Mesh } from '../../assets/mesh';
|
||||
import { Skeleton } from '../../assets/skeleton';
|
||||
import { AABB } from '../../geometry';
|
||||
import { BufferUsageBit, MemoryUsageBit } from '../../gfx/define';
|
||||
import { Vec3 } from '../../math';
|
||||
import { INST_JOINT_ANIM_INFO, UBOSkinningAnimation, UBOSkinningTexture, UNIFORM_JOINT_TEXTURE_BINDING } from '../../pipeline/define';
|
||||
import { Node } from '../../scene-graph';
|
||||
import { Pass } from '../core/pass';
|
||||
import { samplerLib } from '../core/sampler-lib';
|
||||
import { DataPoolManager } from '../data-pool-manager';
|
||||
import { ModelType } from '../scene/model';
|
||||
import { IAnimInfo, IJointTextureHandle, jointTextureSamplerHash } from './skeletal-animation-utils';
|
||||
import { AnimationClip } from '../../core/animation/animation-clip';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { Skeleton } from '../assets/skeleton';
|
||||
import { AABB } from '../../core/geometry';
|
||||
import { BufferUsageBit, MemoryUsageBit } from '../../core/gfx/define';
|
||||
import { Vec3 } from '../../core/math';
|
||||
import { INST_JOINT_ANIM_INFO, UBOSkinningAnimation, UBOSkinningTexture, UNIFORM_JOINT_TEXTURE_BINDING } from '../../core/pipeline/define';
|
||||
import { Node } from '../../core/scene-graph';
|
||||
import { Pass } from '../../core/renderer/core/pass';
|
||||
import { samplerLib } from '../../core/renderer/core/sampler-lib';
|
||||
import { DataPoolManager } from '../skeletal-animation/data-pool-manager';
|
||||
import { ModelType } from '../../core/renderer/scene/model';
|
||||
import { IAnimInfo, IJointTextureHandle, jointTextureSamplerHash } from '../skeletal-animation/skeletal-animation-utils';
|
||||
import { MorphModel } from './morph-model';
|
||||
import { legacyCC } from '../../global-exports';
|
||||
import { Attribute, DescriptorSet, Buffer, BufferInfo } from '../../gfx';
|
||||
import { AABBPool, AABBView } from '../core/memory-pools';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { Attribute, DescriptorSet, Buffer, BufferInfo } from '../../core/gfx';
|
||||
import { AABBPool, AABBView } from '../../core/renderer/core/memory-pools';
|
||||
|
||||
interface IJointsInfo {
|
||||
buffer: Buffer | null;
|
||||
@@ -28,11 +28,11 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { Model } from '../scene/model';
|
||||
import { MorphRenderingInstance } from '../../assets/morph';
|
||||
import { Material } from '../../assets/material';
|
||||
import { RenderingSubMesh } from '../../assets/mesh';
|
||||
import { DescriptorSet } from '../../gfx';
|
||||
import { Model } from '../../core/renderer/scene/model';
|
||||
import { MorphRenderingInstance } from '../assets/morph';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { RenderingSubMesh } from '../../core/assets/rendering-sub-mesh';
|
||||
import { DescriptorSet } from '../../core/gfx';
|
||||
|
||||
export class MorphModel extends Model {
|
||||
private _morphRenderingInstance: MorphRenderingInstance | null = null;
|
||||
@@ -28,90 +28,26 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { Material } from '../../assets/material';
|
||||
import { Mesh, RenderingSubMesh } from '../../assets/mesh';
|
||||
import { Skeleton } from '../../assets/skeleton';
|
||||
import { AABB } from '../../geometry';
|
||||
import { BufferUsageBit, MemoryUsageBit } from '../../gfx/define';
|
||||
import { Mat4, Vec3 } from '../../math';
|
||||
import { UBOSkinning } from '../../pipeline/define';
|
||||
import { Node } from '../../scene-graph/node';
|
||||
import { ModelType } from '../scene/model';
|
||||
import { uploadJointData } from './skeletal-animation-utils';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { RenderingSubMesh } from '../../core/assets/rendering-sub-mesh';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { Skeleton } from '../assets/skeleton';
|
||||
import { AABB } from '../../core/geometry';
|
||||
import { BufferUsageBit, MemoryUsageBit } from '../../core/gfx/define';
|
||||
import { Mat4, Vec3 } from '../../core/math';
|
||||
import { UBOSkinning } from '../../core/pipeline/define';
|
||||
import { Node } from '../../core/scene-graph/node';
|
||||
import { ModelType } from '../../core/renderer/scene/model';
|
||||
import { uploadJointData } from '../skeletal-animation/skeletal-animation-utils';
|
||||
import { MorphModel } from './morph-model';
|
||||
import { DescriptorSet, Buffer, BufferInfo } from '../../gfx';
|
||||
import { AABBPool, AABBView } from '../core/memory-pools';
|
||||
|
||||
export interface IJointTransform {
|
||||
node: Node;
|
||||
local: Mat4;
|
||||
world: Mat4;
|
||||
stamp: number;
|
||||
parent: IJointTransform | null;
|
||||
}
|
||||
|
||||
const stack: IJointTransform[] = [];
|
||||
const pool: Map<string, IJointTransform> = new Map();
|
||||
import { DescriptorSet, Buffer, BufferInfo } from '../../core/gfx';
|
||||
import { AABBPool, AABBView } from '../../core/renderer/core/memory-pools';
|
||||
import { deleteTransform, getTransform, getWorldMatrix, IJointTransform } from '../../core/animation/skeletal-animation-utils';
|
||||
|
||||
const myPatches = [
|
||||
{ name: 'CC_USE_SKINNING', value: true },
|
||||
];
|
||||
|
||||
export function getWorldMatrix (transform: IJointTransform | null, stamp: number) {
|
||||
let i = 0;
|
||||
let res = Mat4.IDENTITY;
|
||||
while (transform) {
|
||||
if (transform.stamp === stamp || transform.stamp + 1 === stamp && !transform.node.hasChangedFlags) {
|
||||
res = transform.world;
|
||||
transform.stamp = stamp;
|
||||
break;
|
||||
}
|
||||
transform.stamp = stamp;
|
||||
stack[i++] = transform;
|
||||
transform = transform.parent;
|
||||
}
|
||||
while (i > 0) {
|
||||
transform = stack[--i];
|
||||
const node = transform.node;
|
||||
Mat4.fromRTS(transform.local, node.rotation, node.position, node.scale);
|
||||
res = Mat4.multiply(transform.world, res, transform.local);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export function getTransform (node: Node, root: Node) {
|
||||
let joint: IJointTransform | null = null;
|
||||
let i = 0;
|
||||
while (node !== root) {
|
||||
const id = node.uuid;
|
||||
if (pool.has(id)) {
|
||||
joint = pool.get(id)!;
|
||||
break;
|
||||
} else { // TODO: object reuse
|
||||
joint = { node, local: new Mat4(), world: new Mat4(), stamp: -1, parent: null };
|
||||
pool.set(id, joint);
|
||||
}
|
||||
stack[i++] = joint;
|
||||
node = node.parent!;
|
||||
joint = null;
|
||||
}
|
||||
let child: IJointTransform;
|
||||
while (i > 0) {
|
||||
child = stack[--i];
|
||||
child.parent = joint;
|
||||
joint = child;
|
||||
}
|
||||
return joint;
|
||||
}
|
||||
|
||||
export function deleteTransform (node: Node) {
|
||||
let transform = pool.get(node.uuid) || null;
|
||||
while (transform) {
|
||||
pool.delete(transform.node.uuid);
|
||||
transform = transform.parent;
|
||||
}
|
||||
}
|
||||
|
||||
function getRelevantBuffers (outIndices: number[], outBuffers: number[], jointMaps: number[][], targetJoint: number) {
|
||||
for (let i = 0; i < jointMaps.length; i++) {
|
||||
const idxMap = jointMaps[i];
|
||||
+6
-3
@@ -28,10 +28,11 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { AnimationClip } from '../animation/animation-clip';
|
||||
import { AnimationClip } from '../../core/animation/animation-clip';
|
||||
import { Skeleton } from '../assets';
|
||||
import { Device } from '../gfx';
|
||||
import { JointAnimationInfo, JointTexturePool } from './models/skeletal-animation-utils';
|
||||
import { Device } from '../../core/gfx';
|
||||
import { JointAnimationInfo, JointTexturePool } from './skeletal-animation-utils';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
export class DataPoolManager {
|
||||
public jointTexturePool: JointTexturePool;
|
||||
@@ -55,3 +56,5 @@ export class DataPoolManager {
|
||||
this.jointAnimationInfo.clear();
|
||||
}
|
||||
}
|
||||
|
||||
legacyCC.internal.DataPoolManager = DataPoolManager;
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module animation
|
||||
*/
|
||||
import { js } from '../../core/utils/js';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { SkeletalAnimation } from './skeletal-animation';
|
||||
/**
|
||||
* Alias of [[SkeletalAnimation]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { SkeletalAnimation as SkeletalAnimationComponent };
|
||||
legacyCC.SkeletalAnimationComponent = SkeletalAnimation;
|
||||
js.setClassAlias(SkeletalAnimation, 'cc.SkeletalAnimationComponent');
|
||||
@@ -27,6 +27,9 @@
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
import './data-pool-manager';
|
||||
|
||||
import { Type } from '../../gfx/define';
|
||||
import { UniformBlock, UniformSampler } from '../../gfx/shader';
|
||||
export * from './skeletal-animation-data-hub';
|
||||
export * from './skeletal-animation-state';
|
||||
export * from './skeletal-animation';
|
||||
export * from './deprecated';
|
||||
+5
-5
@@ -28,11 +28,11 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { Vec3, Quat } from '../math';
|
||||
import { Node } from '../scene-graph';
|
||||
import { IValueProxyFactory } from './value-proxy';
|
||||
import { assertIsNonNullable } from '../data/utils/asserts';
|
||||
import { AnimationState } from './animation-state';
|
||||
import { Vec3, Quat } from '../../core/math';
|
||||
import { Node } from '../../core/scene-graph';
|
||||
import { IValueProxyFactory } from '../../core/animation/value-proxy';
|
||||
import { assertIsNonNullable } from '../../core/data/utils/asserts';
|
||||
import { AnimationState } from '../../core/animation/animation-state';
|
||||
|
||||
export class BlendStateBuffer {
|
||||
private _nodeBlendStates: Map<Node, NodeBlendState> = new Map();
|
||||
+5
-5
@@ -30,11 +30,11 @@
|
||||
|
||||
import {
|
||||
clamp01, Mat4, Quat, Vec3,
|
||||
} from '../math';
|
||||
import { DataPoolManager } from '../renderer/data-pool-manager';
|
||||
import { AnimationClip, IObjectCurveData } from './animation-clip';
|
||||
import { HierarchyPath, isCustomPath, isPropertyPath } from './target-path';
|
||||
import { legacyCC } from '../global-exports';
|
||||
} from '../../core/math';
|
||||
import { DataPoolManager } from './data-pool-manager';
|
||||
import { AnimationClip, IObjectCurveData } from '../../core/animation/animation-clip';
|
||||
import { HierarchyPath, isCustomPath, isPropertyPath } from '../../core/animation/target-path';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
type CurveData = Vec3[] | Quat[] | Mat4[];
|
||||
type ConvertedProps = Record<string, IPropertyCurve>;
|
||||
+7
-7
@@ -28,15 +28,15 @@
|
||||
* @module animation
|
||||
*/
|
||||
|
||||
import { SkinnedMeshRenderer } from '../3d/framework/skinned-mesh-renderer';
|
||||
import { Mat4, Quat, Vec3 } from '../math';
|
||||
import { IAnimInfo, JointAnimationInfo } from '../renderer/models/skeletal-animation-utils';
|
||||
import { Node } from '../scene-graph/node';
|
||||
import { AnimationClip, IRuntimeCurve } from './animation-clip';
|
||||
import { AnimationState } from './animation-state';
|
||||
import { SkinnedMeshRenderer } from '../skinned-mesh-renderer';
|
||||
import { Mat4, Quat, Vec3 } from '../../core/math';
|
||||
import { IAnimInfo, JointAnimationInfo } from './skeletal-animation-utils';
|
||||
import { Node } from '../../core/scene-graph/node';
|
||||
import { AnimationClip, IRuntimeCurve } from '../../core/animation/animation-clip';
|
||||
import { AnimationState } from '../../core/animation/animation-state';
|
||||
import { SkeletalAnimation, Socket } from './skeletal-animation';
|
||||
import { SkelAnimDataHub } from './skeletal-animation-data-hub';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
|
||||
const m4_1 = new Mat4();
|
||||
const m4_2 = new Mat4();
|
||||
+13
-13
@@ -29,21 +29,21 @@
|
||||
*/
|
||||
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { AnimationClip } from '../../animation/animation-clip';
|
||||
import { SkelAnimDataHub } from '../../animation/skeletal-animation-data-hub';
|
||||
import { getWorldTransformUntilRoot } from '../../animation/transform-utils';
|
||||
import { Mesh } from '../../assets/mesh';
|
||||
import { Skeleton } from '../../assets/skeleton';
|
||||
import { AABB } from '../../geometry';
|
||||
import { AnimationClip } from '../../core/animation/animation-clip';
|
||||
import { SkelAnimDataHub } from './skeletal-animation-data-hub';
|
||||
import { getWorldTransformUntilRoot } from '../../core/animation/transform-utils';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import { Skeleton } from '../assets/skeleton';
|
||||
import { AABB } from '../../core/geometry';
|
||||
import {
|
||||
Address, BufferUsageBit, Filter, Format, FormatInfos, MemoryUsageBit, Feature,
|
||||
} from '../../gfx/define';
|
||||
import { Device, Buffer, BufferInfo } from '../../gfx';
|
||||
import { Mat4, Quat, Vec3 } from '../../math';
|
||||
import { UBOSkinningAnimation } from '../../pipeline/define';
|
||||
import { Node } from '../../scene-graph';
|
||||
import { genSamplerHash } from '../core/sampler-lib';
|
||||
import { ITextureBufferHandle, TextureBufferPool } from '../core/texture-buffer-pool';
|
||||
} from '../../core/gfx/define';
|
||||
import { Device, Buffer, BufferInfo } from '../../core/gfx';
|
||||
import { Mat4, Quat, Vec3 } from '../../core/math';
|
||||
import { UBOSkinningAnimation } from '../../core/pipeline/define';
|
||||
import { Node } from '../../core/scene-graph';
|
||||
import { genSamplerHash } from '../../core/renderer/core/sampler-lib';
|
||||
import { ITextureBufferHandle, TextureBufferPool } from '../../core/renderer/core/texture-buffer-pool';
|
||||
|
||||
// change here and cc-skinning.chunk to use other skinning algorithms
|
||||
export const uploadJointData = uploadJointDataLBS;
|
||||
+10
-10
@@ -31,18 +31,18 @@
|
||||
import {
|
||||
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable, editable,
|
||||
} from 'cc.decorator';
|
||||
import { SkinnedMeshRenderer } from '../3d/framework/skinned-mesh-renderer';
|
||||
import { Mat4 } from '../math';
|
||||
import { DataPoolManager } from '../renderer/data-pool-manager';
|
||||
import { Node } from '../scene-graph/node';
|
||||
import { AnimationClip } from './animation-clip';
|
||||
import { Animation } from './animation-component';
|
||||
import { SkinnedMeshRenderer } from '../skinned-mesh-renderer';
|
||||
import { Mat4 } from '../../core/math';
|
||||
import { DataPoolManager } from './data-pool-manager';
|
||||
import { Node } from '../../core/scene-graph/node';
|
||||
import { AnimationClip } from '../../core/animation/animation-clip';
|
||||
import { Animation } from '../../core/animation/animation-component';
|
||||
import { SkelAnimDataHub } from './skeletal-animation-data-hub';
|
||||
import { SkeletalAnimationState } from './skeletal-animation-state';
|
||||
import { getWorldTransformUntilRoot } from './transform-utils';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { AnimationManager } from './animation-manager';
|
||||
import { js } from '../utils/js';
|
||||
import { getWorldTransformUntilRoot } from '../../core/animation/transform-utils';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { AnimationManager } from '../../core/animation/animation-manager';
|
||||
import { js } from '../../core/utils/js';
|
||||
|
||||
@ccclass('cc.SkeletalAnimation.Socket')
|
||||
export class Socket {
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module component
|
||||
*/
|
||||
|
||||
import { SkinnedMeshRenderer } from './skinned-mesh-renderer';
|
||||
import { SkinnedMeshBatchRenderer, SkinnedMeshUnit } from './skinned-mesh-batch-renderer';
|
||||
import { js } from '../../core/utils/js';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
/**
|
||||
* Alias of [[SkinnedMeshRenderer]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { SkinnedMeshRenderer as SkinningModelComponent };
|
||||
legacyCC.SkinningModelComponent = SkinnedMeshRenderer;
|
||||
js.setClassAlias(SkinnedMeshRenderer, 'cc.SkinningModelComponent');
|
||||
/**
|
||||
* Alias of [[SkinnedMeshUnit]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { SkinnedMeshUnit as SkinningModelUnit };
|
||||
legacyCC.SkinningModelUnit = SkinnedMeshUnit;
|
||||
js.setClassAlias(SkinnedMeshUnit, 'cc.SkinningModelUnit');
|
||||
/**
|
||||
* Alias of [[SkinnedMeshBatchRenderer]]
|
||||
* @deprecated Since v1.2
|
||||
*/
|
||||
export { SkinnedMeshBatchRenderer as BatchedSkinningModelComponent };
|
||||
legacyCC.BatchedSkinningModelComponent = SkinnedMeshBatchRenderer;
|
||||
js.setClassAlias(SkinnedMeshBatchRenderer, 'cc.BatchedSkinningModelComponent');
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user