/** * 3D Foundation Project * Copyright 2025 Smithsonian Institution * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import CVDocument from "./CVDocument"; import CVTool, { customElement, html, ToolView } from "./CVTool"; import { EBackgroundStyle } from "@ff/scene/components/CBackground"; //////////////////////////////////////////////////////////////////////////////// export default class CVEnvironmentTool extends CVTool { static readonly typeName: string = "CVEnvironmentTool"; static readonly text = "Environment"; static readonly icon = "environment"; createView() { return new EnvironmentToolView(this); } } //////////////////////////////////////////////////////////////////////////////// @customElement("sv-environment-tool-view") export class EnvironmentToolView extends ToolView { protected firstConnected() { super.firstConnected(); this.classList.add("sv-group", "sv-environment-tool-view"); } protected render() { const tool = this.tool; if (!this.activeDocument) { return html`No active document`; } const setup = this.activeDocument.setup; const grid = setup.grid; const floor = setup.floor; const background = setup.background; const options = [ "Solid", "Linear", "Radial" ]; const style = background.ins.style.getValidatedValue(); const isSolid = style === EBackgroundStyle.Solid; //const isLinear = style === EBackgroundStyle.LinearGradient; const environment = setup.environment; const language = setup.language; //let name0 = isSolid ? " " : (isLinear ? "Top" : "Inner"); //let name1 = isSolid ? "" : (isLinear ? "Btm" : "Outer"); return html`
${!isSolid ? html`` : null}
`; } protected onActiveDocument(previous: CVDocument, next: CVDocument) { if (previous) { const background = previous.setup.background; background.ins.style.off("value", this.onUpdate, this); } if (next) { const background = next.setup.background; background.ins.style.on("value", this.onUpdate, this); } this.requestUpdate(); } protected async setFocus() { await this.updateComplete; const focusElement = this.getElementsByTagName("sv-property-options")[0]as HTMLElement; focusElement.focus(); } protected onClose(event: MouseEvent) { this.parentElement.dispatchEvent(new CustomEvent("close")); event.stopPropagation(); } }