Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: logger #1476

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/effekseer/EffekseerComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { IVector3 } from '../foundation/math/IVector';
import { IEntity } from '../foundation/core/Entity';
import { ComponentToComponentMethods } from '../foundation/components/ComponentTypes';
import { RenderPass } from '../foundation/renderer/RenderPass';
import { Logger } from '../foundation/misc/Logger';

export class EffekseerComponent extends Component {
public static readonly ANIMATION_EVENT_PLAY = 0;
Expand Down Expand Up @@ -70,11 +71,11 @@ export class EffekseerComponent extends Component {

play() {
if (Is.not.exist(this.__context)) {
console.warn('No Effekseer context yet');
Logger.warn('No Effekseer context yet');
return false;
}
if (Is.not.exist(this.__effect)) {
console.warn('No Effekseer effect yet');
Logger.warn('No Effekseer effect yet');
return false;
}

Expand Down Expand Up @@ -192,7 +193,7 @@ export class EffekseerComponent extends Component {
effekseer.setImageCrossOrigin(this.isImageLoadWithCredential ? 'use-credentials' : '');
this.__context = effekseer.createContext();
if (Is.not.exist(this.__context)) {
console.error('Effekseer context creation fails');
Logger.error('Effekseer context creation fails');
return false;
}
const webGLResourceRepository = CGAPIResourceRepository.getWebGLResourceRepository();
Expand All @@ -209,11 +210,11 @@ export class EffekseerComponent extends Component {
}
};
const onError = (message: string, path: string) => {
console.error(message, path);
Logger.error(message + ', ' + path);
};
if (this.type === 'efkpkg') {
if (Is.not.exist(EffekseerComponent.Unzip)) {
console.error('Please Set an Unzip object to EffekseerComponent.Unzip');
Logger.error('Please Set an Unzip object to EffekseerComponent.Unzip');
return false;
}
this.__effect = this.__context.loadEffectPackage(
Expand Down Expand Up @@ -251,7 +252,7 @@ export class EffekseerComponent extends Component {
}
},
() => {
console.error('Failed to initialize Effekseer');
Logger.error('Failed to initialize Effekseer');
}
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { IEntity } from '../../core/Entity';
import { ComponentToComponentMethods } from '../ComponentTypes';
import { ProcessStage } from '../../definitions';
import { ICameraControllerEntity } from '../../helpers/EntityHelper';
import { Logger } from '../../misc/Logger';

/**
* The Component that controls camera posture.
Expand All @@ -38,7 +39,7 @@ export class CameraControllerComponent extends Component {
} else if (type === CameraControllerType.WalkThrough) {
this.__cameraController = new WalkThroughCameraController(this);
} else {
console.warn('Not support type!');
Logger.warn('Not support type!');
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/foundation/components/Mesh/MeshComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { BlendShapeComponent } from '../BlendShape/BlendShapeComponent';
import { ComponentToComponentMethods } from '../ComponentTypes';
import { RaycastResultEx1 } from '../../geometry/types/GeometryTypes';
import { assertExist } from '../../misc/MiscUtil';
import { Logger } from '../../misc/Logger';

export class MeshComponent extends Component {
private __viewDepth = -Number.MAX_VALUE;
Expand Down Expand Up @@ -103,7 +104,7 @@ export class MeshComponent extends Component {
}

static alertNoMeshSet(meshComponent: MeshComponent) {
console.debug('No mesh is set on this MeshComponent:' + meshComponent.componentSID);
Logger.debug('No mesh is set on this MeshComponent:' + meshComponent.componentSID);
}

castRay(srcPointInWorld: Vector3, directionInWorld: Vector3, dotThreshold = 0): RaycastResultEx1 {
Expand Down
3 changes: 2 additions & 1 deletion src/foundation/components/Skeletal/SkeletalComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IEntity } from '../../core/Entity';
import { ComponentToComponentMethods } from '../ComponentTypes';
import { Is } from '../../misc';
import { createGroupEntity } from '../SceneGraph/createGroupEntity';
import { Logger } from '../../misc/Logger';

export class SkeletalComponent extends Component {
public _jointIndices: Index[] = [];
Expand Down Expand Up @@ -75,7 +76,7 @@ export class SkeletalComponent extends Component {
}
SkeletalComponent.__tookGlobalDataNum++;
} else {
console.warn('The actual number of Skeleton generated exceeds Config.maxSkeletonNumber.');
Logger.warn('The actual number of Skeleton generated exceeds Config.maxSkeletonNumber.');
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/foundation/definitions/CompositionType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../types/CommonTypes';
import type { ComponentTypeEnum } from './ComponentType';
import { Gltf2AccessorCompositionTypeString } from '../../types/glTF2';
import { Logger } from '../misc/Logger';

export interface CompositionTypeEnum extends EnumIO {
webgpu: string;
Expand Down Expand Up @@ -494,7 +495,7 @@ function vectorFrom(componentN: number): CompositionTypeEnum {
str = 'vec4';
break;
default:
console.error('not found appropriate Vectors');
Logger.error('not found appropriate Vectors');
}
return _fromString({ typeList, str }) as CompositionTypeEnum;
}
Expand Down
3 changes: 2 additions & 1 deletion src/foundation/definitions/ShaderSemanticsInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Count } from '../../types/CommonTypes';
import { Logger } from '../misc/Logger';
import { ComponentTypeEnum } from './ComponentType';
import { CompositionType, CompositionTypeEnum } from './CompositionType';
import { ShaderSemanticsEnum, ShaderSemanticsName } from './ShaderSemantics';
Expand Down Expand Up @@ -36,7 +37,7 @@ export function calcAlignedByteLength(semanticInfo: ShaderSemanticsInfo) {
if (maxArrayLength != null) {
alignedByteLength *= maxArrayLength;
} else {
console.error('semanticInfo has invalid maxIndex!');
Logger.error('semanticInfo has invalid maxIndex!');
alignedByteLength *= 100;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/foundation/exporter/Gltf2ExporterEffekseer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { WellKnownComponentTIDs } from '../components/WellKnownComponentTIDs';
import { IEntity } from '../core';
import { ISceneGraphEntity } from '../helpers/EntityHelper';
import { Is } from '../misc/Is';
import { Logger } from '../misc/Logger';
import { createAndAddGltf2BufferView } from './Gltf2ExporterOps';

export function createEffekseer(json: Gltf2Ex, entities: ISceneGraphEntity[]) {
Expand Down Expand Up @@ -39,7 +40,7 @@ export function createEffekseer(json: Gltf2Ex, entities: ISceneGraphEntity[]) {
} else if (Is.exist(effekseerComponent.uri)) {
effekseer.uri = effekseerComponent.uri;
} else {
console.error('no real effect data.');
Logger.error('no real effect data.');
}

__createEffekseerTimeline(effekseerComponent.entity, effekseer);
Expand Down
5 changes: 3 additions & 2 deletions src/foundation/geometry/Mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { IMesh, RaycastResultEx1 } from './types/GeometryTypes';
import { IMeshEntity } from '../helpers/EntityHelper';
import { MeshComponent } from '../components/Mesh/MeshComponent';
import { ProcessStage } from '../definitions/ProcessStage';
import { Logger } from '../misc/Logger';

/**
* The Mesh class.
Expand Down Expand Up @@ -232,7 +233,7 @@ export class Mesh implements IMesh {
const primitive = this.__primitives[i];
const vertexHandles = primitive.vertexHandles as VertexHandles;
if (Is.undefined(vertexHandles)) {
console.warn('Need to create 3DAPIVertexData before update VAO');
Logger.warn('Need to create 3DAPIVertexData before update VAO');
continue;
}

Expand Down Expand Up @@ -570,7 +571,7 @@ export class Mesh implements IMesh {

const validate = Math.abs(abc.x) < Number.EPSILON;
if (validate) {
console.assert(validate, 'Polygons or polygons on UV are degenerate!');
Logger.assert(validate, 'Polygons or polygons on UV are degenerate!');
return Vector3.fromCopyArray([0, 0, 0]);
}

Expand Down
3 changes: 2 additions & 1 deletion src/foundation/geometry/Primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { Config } from '../core/Config';
import { isErr } from '../misc/Result';
import { RnException } from '../misc/RnException';
import { Mesh } from './Mesh';
import { Logger } from '../misc/Logger';

export type Attributes = Map<VertexAttributeSemanticsJoinedString, Accessor>;

Expand Down Expand Up @@ -527,7 +528,7 @@ export class Primitive extends RnObject {

setBlendShapeTargets(targets: Array<Attributes>) {
if (Primitive.__primitiveUidIdxHasMorph.size >= Config.maxVertexPrimitiveNumberInShader) {
console.error(
Logger.error(
'Primitive.__primitiveUidsHasMorph.size exceeds the Config.maxMorphPrimitiveNumber'
);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/foundation/geometry/shapes/Sphere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Vector3 } from '../../math/Vector3';
import { Count } from '../../../types/CommonTypes';
import { IShape } from './IShape';
import { PhysicsProperty } from '../../physics/PhysicsProperty';
import { Logger } from '../../misc/Logger';

/**
* The argument descriptor for Plane primitives
Expand Down Expand Up @@ -40,7 +41,7 @@ export class Sphere extends IShape {
const normals = [];

if (Math.abs(desc.radius) < Number.EPSILON) {
console.warn(
Logger.warn(
'The argument radius is zero / nearly zero. Rn will take the radius as 0.001 for safety. Check your code.'
);
desc.radius = 0.001;
Expand Down
15 changes: 8 additions & 7 deletions src/foundation/gizmos/ScaleGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Quaternion } from '../math/Quaternion';
import { Vector3 } from '../math/Vector3';
import { Vector4 } from '../math/Vector4';
import { Is } from '../misc/Is';
import { Logger } from '../misc/Logger';
import { assertExist } from '../misc/MiscUtil';
import { getEvent, InputManager, INPUT_HANDLING_STATE_GIZMO_SCALE } from '../system/InputManager';
import { Gizmo } from './Gizmo';
Expand Down Expand Up @@ -582,19 +583,19 @@ export class ScaleGizmo extends Gizmo {
if (xResult.result) {
assertExist(xResult.data);
this.__pickStatedPoint = rotMat.multiplyVector(xResult.data.position.clone());
console.log('Down:' + this.__pickStatedPoint.toStringApproximately());
Logger.debug('Down:' + this.__pickStatedPoint.toStringApproximately());
ScaleGizmo.__activeAxis = 'x';
}
if (yResult.result) {
assertExist(yResult.data);
this.__pickStatedPoint = rotMat.multiplyVector(yResult.data.position.clone());
console.log('Down:' + this.__pickStatedPoint.toStringApproximately());
Logger.debug('Down:' + this.__pickStatedPoint.toStringApproximately());
ScaleGizmo.__activeAxis = 'y';
}
if (zResult.result) {
assertExist(zResult.data);
this.__pickStatedPoint = rotMat.multiplyVector(zResult.data.position.clone());
console.log('Down:' + this.__pickStatedPoint.toStringApproximately());
Logger.debug('Down:' + this.__pickStatedPoint.toStringApproximately());
ScaleGizmo.__activeAxis = 'z';
}

Expand Down Expand Up @@ -648,7 +649,7 @@ export class ScaleGizmo extends Gizmo {
const position = rotMat.multiplyVector(xResult.data.position);
pickInMovingPoint = Vector3.fromCopy3(position.x, pickInMovingPoint.y, pickInMovingPoint.z);
// pickInMovingPoint = Vector3.fromCopy3(xResult.data.position.x, pickInMovingPoint.y, pickInMovingPoint.z);
console.log('Move:' + xResult.data.position.toStringApproximately());
Logger.debug('Move:' + xResult.data.position.toStringApproximately());
}
InputManager.disableCameraController();
}
Expand All @@ -661,7 +662,7 @@ export class ScaleGizmo extends Gizmo {
const position = rotMat.multiplyVector(yResult.data.position);
pickInMovingPoint = Vector3.fromCopy3(pickInMovingPoint.x, position.y, pickInMovingPoint.z);
// pickInMovingPoint = Vector3.fromCopy3(pickInMovingPoint.x, yResult.data.position.y, pickInMovingPoint.z);
console.log('Move:' + yResult.data.position.toStringApproximately());
Logger.debug('Move:' + yResult.data.position.toStringApproximately());
}
InputManager.disableCameraController();
}
Expand All @@ -674,7 +675,7 @@ export class ScaleGizmo extends Gizmo {
const position = rotMat.multiplyVector(zResult.data.position);
pickInMovingPoint = Vector3.fromCopy3(pickInMovingPoint.x, pickInMovingPoint.y, position.z);
// pickInMovingPoint = Vector3.fromCopy3(pickInMovingPoint.x, pickInMovingPoint.y, zResult.data.position.z);
console.log('Move:' + zResult.data.position.toStringApproximately());
Logger.debug('Move:' + zResult.data.position.toStringApproximately());
}
InputManager.disableCameraController();
}
Expand All @@ -686,7 +687,7 @@ export class ScaleGizmo extends Gizmo {
1 / aabb.lengthCenterToCorner
);

console.log(`${this.__target.uniqueName}: ` + deltaVector3.toStringApproximately());
Logger.debug(`${this.__target.uniqueName}: ` + deltaVector3.toStringApproximately());

if (ScaleGizmo.__space === 'local') {
this.__deltaPoint = Vector3.add(this.__targetScaleBackup, deltaVector3);
Expand Down
9 changes: 5 additions & 4 deletions src/foundation/gizmos/TranslationGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { Gizmo } from './Gizmo';
import { IQuaternion } from '../math';
import { createGroupEntity } from '../components/SceneGraph/createGroupEntity';
import { createMeshEntity } from '../components/MeshRenderer/createMeshEntity';
import { Logger } from '../misc/Logger';

declare let window: any;

Expand Down Expand Up @@ -509,19 +510,19 @@ export class TranslationGizmo extends Gizmo {
if (xResult.result) {
assertExist(xResult.data);
this.__pickStatedPoint = rotMat.multiplyVector(xResult.data.position.clone());
console.log('Down:' + this.__pickStatedPoint.toStringApproximately());
Logger.debug('Down:' + this.__pickStatedPoint.toStringApproximately());
TranslationGizmo.__activeAxis = 'x';
}
if (yResult.result) {
assertExist(yResult.data);
this.__pickStatedPoint = rotMat.multiplyVector(yResult.data.position.clone());
console.log('Down:' + this.__pickStatedPoint.toStringApproximately());
Logger.debug('Down:' + this.__pickStatedPoint.toStringApproximately());
TranslationGizmo.__activeAxis = 'y';
}
if (zResult.result) {
assertExist(zResult.data);
this.__pickStatedPoint = rotMat.multiplyVector(zResult.data.position.clone());
console.log('Down:' + this.__pickStatedPoint.toStringApproximately());
Logger.debug('Down:' + this.__pickStatedPoint.toStringApproximately());
TranslationGizmo.__activeAxis = 'z';
}

Expand Down Expand Up @@ -613,7 +614,7 @@ export class TranslationGizmo extends Gizmo {
return;
}

console.log(`${this.__target.uniqueName}: ` + deltaVector3.toStringApproximately());
Logger.debug(`${this.__target.uniqueName}: ` + deltaVector3.toStringApproximately());

if (TranslationGizmo.__space === 'local') {
this.__deltaPoint = Vector3.add(deltaVector3, this.__targetPointBackup);
Expand Down
7 changes: 4 additions & 3 deletions src/foundation/importer/AnimationAssigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { RnM2Vrma } from '../../types';
import { Vector3 } from '../math';
import { GlobalRetargetReverse } from '../components/Skeletal/AnimationRetarget/GlobalRetargetReverse';
import { AnimationStateComponent } from '../components/AnimationState/AnimationStateComponent';
import { Logger } from '../misc/Logger';

type RetargetMode = 'none' | 'global' | 'absolute';

Expand Down Expand Up @@ -186,7 +187,7 @@ export class AnimationAssigner {
const rnEntities = rootEntity.getTagValue('rnEntities')! as ISceneGraphEntity[];
return rnEntities[dstBoneNodeId];
} else {
console.log(
Logger.info(
`humanoidBoneName: ${humanoidBoneName}, nodeIndex: ${nodeIndex}, nodeName: ${nodeName}`
);
return void 0;
Expand All @@ -212,7 +213,7 @@ export class AnimationAssigner {
const rnEntities = rootEntity.getTagValue('rnEntities')! as ISceneGraphEntity[];
return rnEntities[dstBoneNodeId];
} else {
console.log(
Logger.info(
`humanoidBoneName: ${humanoidBoneName}, nodeIndex: ${nodeIndex}, nodeName: ${nodeName}`
);
return void 0;
Expand Down Expand Up @@ -244,7 +245,7 @@ export class AnimationAssigner {

return rnEntity;
} else {
console.log(`humanoidBoneName: ${humanoidBoneName}, nodeIndex: ${nodeIndex}`);
Logger.info(`humanoidBoneName: ${humanoidBoneName}, nodeIndex: ${nodeIndex}`);
return void 0;
}
}
Expand Down
Loading
Loading