// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // World-upright child preview // Not compiled or tested in-world // Setup: Put in nonphysical child; owner-touch previews/restores. Keep root still. // Stop / restore: Owner-touch again to restore the startup snapshot before removal or reset, unless setup describes a different cycle. Do not relink during a preview. // Notes: Use a spare modifiable build. Saved state lives only in script memory. Converts world orientation into root-local rotation. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer preview; rotation home; default { state_entry() { home=llGetLocalRot(); } touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(llGetLinkNumber()<2||llGetStatus(STATUS_PHYSICS))return; vector forward=llRot2Fwd(home*llGetRootRotation()); forward.z=0.0; if(llVecMag(forward)<0.01)return; preview=!preview; if(preview) { rotation root=llGetRootRotation(); vector f=llRot2Fwd(home*root); float yaw=llAtan2(f.y,f.x); llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROT_LOCAL,llEuler2Rot(<0.0,0.0,yaw>)/root]); } else { llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROT_LOCAL,home]); } } }