| "replace": { | "replace": { | ||||
| "dependencies": {}, | "dependencies": {}, | ||||
| "peerDependencies": { | "peerDependencies": { | ||||
| "threepipe": "^0.0.26", | |||||
| "@threepipe/plugin-tweakpane": "^0.2.0" | |||||
| "threepipe": "^0.0.50", | |||||
| "@threepipe/plugin-tweakpane": "^0.6.1" | |||||
| } | } | ||||
| } | } | ||||
| } | } |
| this.getWorldPosition(this._positionWorld) | this.getWorldPosition(this._positionWorld) | ||||
| iCameraCommons.setDirty.call(this, options) | iCameraCommons.setDirty.call(this, options) | ||||
| if (options?.last !== false) | if (options?.last !== false) | ||||
| this._camUi.forEach(u=>u?.uiRefresh?.(false, 'postFrame', 1)) // because camera changes a lot. so we dont want to deep refresh ui on every change | this._camUi.forEach(u=>u?.uiRefresh?.(false, 'postFrame', 1)) // because camera changes a lot. so we dont want to deep refresh ui on every change | ||||
| } | } | ||||
| /** | /** | ||||
| * Serializes this camera with controls to JSON. | * Serializes this camera with controls to JSON. | ||||
| * @param meta - metadata for serialization | * @param meta - metadata for serialization | ||||
| * @param baseOnly - Calls only super.toJSON, does internal three.js serialization. Set it to true only if you know what you are doing. | |||||
| * @param _internal - Calls only super.toJSON, does internal three.js serialization and `@serialize` tags. Set it to true only if you know what you are doing. This is used in Serialization->serializer | |||||
| */ | */ | ||||
| toJSON(meta?: any, baseOnly = false): any { | |||||
| if (baseOnly) return super.toJSON(meta) | |||||
| return ThreeSerialization.Serialize(this, meta, true) | |||||
| toJSON(meta?: any, _internal = false): any { | |||||
| if (_internal) return { | |||||
| ...super.toJSON(meta), | |||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | |||||
| } | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| fromJSON(data: any, meta?: any): this | null { | fromJSON(data: any, meta?: any): this | null { |
| /** | /** | ||||
| * Serializes this camera with controls to JSON. | * Serializes this camera with controls to JSON. | ||||
| * @param meta - metadata for serialization | * @param meta - metadata for serialization | ||||
| * @param baseOnly - Calls only super.toJSON, does internal three.js serialization. Set it to true only if you know what you are doing. | |||||
| * @param _internal - Calls only super.toJSON, does internal three.js serialization and `@serialize` tags. Set it to true only if you know what you are doing. This is used in Serialization->serializer | |||||
| */ | */ | ||||
| toJSON(meta?: any, baseOnly = false): any { | |||||
| if (baseOnly) return super.toJSON(meta) | |||||
| toJSON(meta?: any, _internal = false): any { | |||||
| if (_internal) return { | |||||
| ...super.toJSON(meta), | |||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | |||||
| } | |||||
| // todo add camOptions for backwards compatibility? | // todo add camOptions for backwards compatibility? | ||||
| return ThreeSerialization.Serialize(this, meta, true) | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| fromJSON(data: any, meta?: any): this | null { | fromJSON(data: any, meta?: any): this | null { | ||||
| // todo: add check for OrbitControls being not deserialized(inited properly) if it doesn't exist yet (if it is not inited properly) | // todo: add check for OrbitControls being not deserialized(inited properly) if it doesn't exist yet (if it is not inited properly) | ||||
| // console.log(JSON.parse(JSON.stringify(data))) | // console.log(JSON.parse(JSON.stringify(data))) | ||||
| ThreeSerialization.Deserialize(data, this, meta, true) | ThreeSerialization.Deserialize(data, this, meta, true) | ||||
| this.refreshAspect(false) | |||||
| this.setDirty({change: 'deserialize'}) | this.setDirty({change: 'deserialize'}) | ||||
| return this | return this | ||||
| } | } |
| ...super.toJSON(meta), | ...super.toJSON(meta), | ||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ||||
| } | } | ||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with baseOnly=true, that's why we set isThis to false. | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| /** | /** |
| ...super.toJSON(meta), | ...super.toJSON(meta), | ||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ||||
| } | } | ||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with baseOnly=true, that's why we set isThis to false. | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| /** | /** |
| ...super.toJSON(meta), | ...super.toJSON(meta), | ||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ||||
| } | } | ||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with baseOnly=true, that's why we set isThis to false. | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| /** | /** |
| ...super.toJSON(meta), | ...super.toJSON(meta), | ||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ||||
| } | } | ||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with baseOnly=true, that's why we set isThis to false. | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| /** | /** |
| ...super.toJSON(meta), | ...super.toJSON(meta), | ||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ||||
| } | } | ||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with baseOnly=true, that's why we set isThis to false. | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| /** | /** |
| ...super.toJSON(meta), | ...super.toJSON(meta), | ||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ||||
| } | } | ||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with baseOnly=true, that's why we set isThis to false. | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| /** | /** |
| ...super.toJSON(meta), | ...super.toJSON(meta), | ||||
| ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ...ThreeSerialization.Serialize(this, meta, true), // this will serialize the properties of this class(like defined with @serialize and @serialize attribute) | ||||
| } | } | ||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with baseOnly=true, that's why we set isThis to false. | |||||
| return ThreeSerialization.Serialize(this, meta, false) // this will call toJSON again, but with _internal=true, that's why we set isThis to false. | |||||
| } | } | ||||
| /** | /** |